企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
#### 使用正则表达式 ``` function toThousands(number){ //判断是整数还是小数parseInt(number)==number var n = 0; var re = ''; if(number){ if(parseInt(number, 10) == number){ re = /(\d{1,3})(?=(\d{3})+(?:$|\D))/g; }else{ re = /(\d{1,3})(?=(\d{3})+(?:\.|\D))/g; } var renumber = number.toString(); n = renumber.replace(re,"$1,"); return n ? n : 0; } return n; } ```