Número com vírgulas JS
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
kripi__
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
var number = 3500;
console.log(new Intl.NumberFormat().format(number));
// → '3,500' if in US English locale