js代码实现千分位分隔
function micrometer(n) {
var str = n.toString()
var str1 = ''
var n = 1
var len=str.length
for (var i = str.length-1;i>=0 ;i--) {
if(n%3==0 && str[i-1]!=undefined){
str=str.slice(0,i)+','+str.slice(i,str.length)
}
n++
}
return (str);
}
console.log( micrometer(66574) );
console.log( micrometer(6689342) )
console.log( micrometer(1234643245) )
console.log( micrometer(66574) );
console.log( micrometer(545676) );
console.log( micrometer(332) );
console.log( micrometer(3312) );