Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
110
rated 0 times [  114] [ 4]  / answers: 1 / hits: 62780  / 10 Years ago, tue, july 15, 2014, 12:00:00

Is there a way to get number.toLocaleString() with 4 digits after the comma?



Example:



var number = 49.9712;
document.getElementById('id').innerText = number.toLocaleString();


Result:
49,9712



But now it always returns number with 2 digits after comma:
49,97


More From » numbers

 Answers
31

You may use second argument to provide some options. In your case, with default locale:



number.toLocaleString(undefined, { minimumFractionDigits: 4 })

[#70204] Friday, July 11, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
keana

Total Points: 452
Total Questions: 97
Total Answers: 81

Location: Barbados
Member since Sun, Nov 27, 2022
2 Years ago
;