|
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
|
|
|