This article uses 65,541,694,158 as an example to introduce the method of adding thousands of characters. The code is relatively simple and easy to understand. The specific code is as follows:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Add a thousand semicolon to the character</title> <script type="text/javascript"> var str = '2359844564654'; function test3(str) { var iNum = str.length%3; //Remainer var prev = ''; var arr = []; var iNow = 0; var tmp = ''; if(iNum !=0) { prev = str.substring(0,iNum); //Intercept the remainder arr.push(prev); } str = str.substring(iNum); for(var i=0;i<str.length;i++) { iNow++; tmp +=str[i]; if(iNow ==3 && tmp) { arr.push(tmp); tmp = ''; iNow = 0; } } return arr.join(','); } alert(test3(str)); </script> </head> <body> <p></p> </body> </html>The above is what I introduced to you based on JS how to add thousands of characters (65, 541, 694, 158). I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!