Let's say we have these 2 values
1.230
That means in Italy one thousand and 230, if an American had to write that, would write
1,230
Currently using:
myValue.toLocaleString('it');
For US we should be using myValue.toLocaleString('en-US');
How would we detect the correct number format we should be displaying?
Let's say we have these 2 values
1.230
That means in Italy one thousand and 230, if an American had to write that, would write
1,230
Currently using:
myValue.toLocaleString('it');
For US we should be using myValue.toLocaleString('en-US');
How would we detect the correct number format we should be displaying?
Share Improve this question asked May 9, 2020 at 9:12 rob.mrob.m 10.6k21 gold badges88 silver badges175 bronze badges 1- Related: Javascript toFixed localized?. – Sebastian Simon Commented Jan 19, 2023 at 0:51
2 Answers
Reset to default 8Do you want something like that?
myValue.toLocaleString(navigator.language)
You can use Intl.NumberFormat as
var number = 3500;
console.log(new Intl.NumberFormat().format(number));