码迷,mamicode.com
首页 > 其他好文 > 详细

千分位

时间:2017-08-08 20:08:34      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:var   string   span   bsp   color   return   调用   ring   result   

// 千分位 直接调用即可
function toThousands(num) {
    var num = (num || 0).toString(), result = ‘‘;
    while (num.length > 3) {
        result = ‘,‘ + num.slice(-3) + result;
        num = num.slice(0, num.length - 3);
    }
    if (num) { result = num + result; }
    return result;
}

千分位

标签:var   string   span   bsp   color   return   调用   ring   result   

原文地址:http://www.cnblogs.com/hai-cheng/p/7308216.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!