狄烁STEC的试验场

hello earth

导航

2011年5月16日 #

为目标数字添加逗号分隔,由 baidu.number.comma 想到的

摘要: 2011.05.17更新:测试数据还不够广泛,在同事的机器上用IE8测试时出现 baidu.number.comma 比 comma 耗时更少的情况,等有时间了还要进一步测试。逛博客的时候看到了《JavaScript 散记:Tangram》这篇文章,其中提到了给数字添加逗号分隔符的算法。算法如下:baidu.number.comma = function (source, length) { if (!length || length < 1) { length = 3; } source = String(source).split("."); source[0] 阅读全文

posted @ 2011-05-16 15:56 狄烁STEC 阅读(392) 评论(2) 推荐(0) 编辑