function commafy(num) {
num = num + '';
var reg = /(-?\d+)(\d{3})/;
if(reg.test(num)){
num = num.replace(reg, '$1,$2');
}
return num;
}
commafy(1234);
function commafy(num) {
num = num + '';
var reg = /(-?\d+)(\d{3})/;
if(reg.test(num)){
num = num.replace(reg, '$1,$2');
}
return num;
}
commafy(1234);