Number toLocaleString() method

Find out all the information about the JavaScript toLocaleString() method of the number

Format the number according to the locale.

By default, the locale is American English:

new Number(21.2).toLocaleString() //21.2

We can pass the locale as the first parameter:

new Number(21.2).toLocaleString('it') //21,2

This is Oriental Arabic

new Number(21.2).toLocaleString('ar-EG') //٢١٫٢

You can add many options, I suggest you take a lookMDN pageunderstand more.

Download mine for freeJavaScript beginner's manual

More js tutorials: