金额格式化方法集锦

在网上搜罗的金额格式化方法

方法一

    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;
    }
原文地址:https://www.cnblogs.com/ToBeBest/p/6265672.html