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

$格式化 revenue

时间:2018-12-27 19:03:02      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:replace   for   and   this   fine   atm   cti   ati   eve   

Number.prototype.formatMoney = function (places, symbol, thousand, decimal) {
places = !isNaN(places = Math.abs(places)) ? places : 2;
symbol = symbol !== undefined ? symbol : "$";
thousand = thousand || ",";
decimal = decimal || ".";
var number = this,
negative = number < 0 ? "-" : "",
i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return symbol + negative + (j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) + (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : "");
};

$格式化 revenue

标签:replace   for   and   this   fine   atm   cti   ati   eve   

原文地址:https://www.cnblogs.com/cylblogs/p/10185230.html

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