Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Replaced the last snippet with Chris's number_format idea. So here we are.

Syntax: number.commify()

Number.prototype.commify = function(a) {
     return (a = this + "").replace(/\d(?!\d*$)/g, function(b, c) { return c && (c - a.split(".")[0].length) % 3 < 1 ? "," + b : b; });
}


Edit: Forgot the return statement and fixed a silly oversight.


Last Edit: Aug 22, 2010 6:15:56 GMT by Aaron

newBookmarkLockedFalling