When I encountered a requirement in the project, I wanted to change the Chinese-style display of Arabic numerals to European-style, that is, every three digits are displayed, separated by commas in the middle, such as 12345678 to 12, 345, 678. The following is the specific implementation of the javascript code:
var iValue = 20002365879; //The number to be converted var sValue = iValue+'';var aValue = new Array();var iNum = sValue.length%3;var aResult; //Conversion result var index = 0;if(sValue.length<=3){console.log(sValue);}else{if(iNum == 0){for(var i=0; i<sValue.length; i=i+3){aValue[index] = sValue[i]+''+sValue[i+1]+''+sValue[i+2];index++;}}else if(iNum == 1){aValue[0] = sValue[0];index = 1;for(var i=1; i<sValue.length; i=i+3){aValue[index] = sValue[i]+''+sValue[i+1]+''+sValue[i+2];index++;}}else if(iNum == 2){aValue[0] = sValue[0]+''+sValue[1];index = 1;for(var i=2; i<sValue.length; i=i+3){aValue[index] = sValue[i]+''+sValue[i+1]+''+sValue[i+2];index++;}}aResult = aValue.join(',');console.log(aResult.toString());//Output 20,002,365,879}The above simple example of JavaScript converting Chinese digital formats into European digital formats 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.