JavaScript format number with commas using toLocaleString()

JavaScript format number with commas using toLocaleString()

8 months ago
raja $aqm1-J6ZlN

const number = 1234567.89;

const formattedNumber = number.toLocaleString();

console.log(formattedNumber)

// Output: "1,234,567.89"

https://medium.com/@onlinemsr/big-numbers-no-worries-javascript-format-number-with-commas-17ec7f878834