Examples are as follows:
/** * Convert the number format to thousands of digits*@param{Object}num */function commafy(num){ if((num+"").Trim()==""){ return""; } if(isNaN(num)){ return""; } num = num+""; if(/^.*/..*$/.test(num)){ varpointIndex =num.lastIndexOf("."); varintPart = num.substring(0,pointIndex); varpointPart = num.substring(pointIndex+1,num.length); intPart = intPart +""; var re =/(-?/d+)(/d{3})/ while(re.test(intPart)){ intPart =intPart.replace(re,"$1,$2") } num = intPart+"."+pointPart; }else{ num = num +""; var re =/(-?/d+)(/d{3})/ while(re.test(num)){ num =num.replace(re,"$1,$2") } } return num;}/** * Remove the thousandquartile*@param{Object}num */function delcommafy(num){ if((num+"").Trim()==""){ return""; } num=num.replace(/,/gi,''); returnnum;}The above article on JS implements the mutual conversion of digital formats of thousands of digits is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.