On browsers that support the ECMAScript® 2016 Internationalization API Specification (ECMA-402), you can use an Intl.NumberFormat
instance:
var nf = Intl.NumberFormat();
var x = 42000000;
console.log(nf.format(x)); // 42,000,000 in many locales
// 42.000.000 in many other locales
if (typeof Intl === "undefined" || !Intl.NumberFormat) {_x000D_
console.log("This browser doesn't support Intl.NumberFormat");_x000D_
} else {_x000D_
var nf = Intl.NumberFormat();_x000D_
var x = 42000000;_x000D_
console.log(nf.format(x)); // 42,000,000 in many locales_x000D_
// 42.000.000 in many other locales_x000D_
}
_x000D_