Print numbers with commas as thousand separators in JavaScript
We can use Number.prototype.toLocaleString()
method which returns a string with a language-sensitive representation such as thousand separator,currency etc of the number.
let n = Number(123456789); console.log(n.toLocaleString()); //123,456,789