实现数字的千分位显示方式
文章目录
- 方法一:利用正则表达式实现
let num = 12312312312;
let thousand = num.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
console.log(thousand);
let num = 12312312312;
let thousand = num.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
console.log(thousand);
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论