126186312===>126,186,312
1、正则表达式
var result = "12345678".replace(/(?=\d{3}$)/g, ",");
console.log(result);
// => "12345,678"
2、toLocaleString()方法
var num = 123456789
console.log(num.toLocaleString())//123,456,789
126186312===>126,186,312
1、正则表达式
var result = "12345678".replace(/(?=\d{3}$)/g, ",");
console.log(result);
// => "12345,678"
2、toLocaleString()方法
var num = 123456789
console.log(num.toLocaleString())//123,456,789