2024年07月25日 建站教程
function toThousands(num) {
var result = [ ], counter = 0;
num = (num || 0).toString().split('');
for (var i = num.length - 1; i >= 0; i--) {
counter++;
result.unshift(num[i]);
if (!(counter % 3) && i != 0) { result.unshift(','); }
}
return result.join('');
}
//输出
console.log(toThousands(9992019))
//结果 9,992,019
本文链接:http://so.lmcjl.com/news/9138/