You can use the toLocaleString()
function, which convert a number to a string giving it the specified local format (and if you do not specify any, it will format the number to the location that has the default browser).
The format you can pass as the first parameter and must conform to the specified format here .
NOTE - A problem with this function: Safari does not support it in any of its versions, and it does not work in IE versions prior to 11.
Here is an example:
var number = 46786.62;
// sin parámetros será el formato por defecto de tu navegador
console.log("Formato automático --- " + number.toLocaleString());
// le puedes pasar un código de locale específico
console.log("Formato en EE.UU. ---- " + number.toLocaleString("en-US"));
console.log("Formato de España ---- " + number.toLocaleString("es-ES"));