Javascript Number numberformat(n)

Description

Javascript Number numberformat(n)


Number.prototype.numberformat = function (n) {
    var re = '\\d(?=(\\d{' + (3 || 3) + '})+' + (n > 0 ? '\\.' : '$') + ')';
    return this.toFixed(Math.max(0, ~~n)).replace(new RegExp(re, 'g'), '$&,');
};



PreviousNext

Related