金额格式化

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;
}

 

posted @ 2018-01-02 10:51  邹柯  阅读(151)  评论(0编辑  收藏  举报