function comma (num) {var source = String (num). Split ("."); /divide by decimal point into 2 parts source[0] = source[0].replace (New RegExp (' (\\d) (? = (\\d{3}) +$) ', ' IG '), "$,");//Divide the integer part only to break the return Source.join ("."); /Then merge the fractional parts in};
//I modified-(at present my own best)function retaineddecimalplaces (num, del) {//value: num decimal bit: del if (del! = 0) {num = parsefloat (num). toFixed (DEL);//Keep decimal and four Five-in} var Source = String (num). Split ("."); /divide by decimal point into 2 parts source[0] = source[0].replace (New RegExp (' (\\d) (? = (\\d{3}) +$) ', ' IG '), "$,");//Divide the integer part only to break the return Source.join ("."); /Then merge the fractional parts in}; Retaineddecimalplaces (120000.888,2)
From for notes (Wiz)
Thousand separators, reserved decimals