Number.prototype.toCurrency = function() { var value; if (isNaN(this) || !isFinite(this)) { return '-'; } value = Math.abs(this).toFixed(2); value = value.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); return (this < 0 ? '-$' : '$') + value; }; Number.prototype.toPercent = function() { if (isNaN(this) || !isFinite(this)) { return '-'; } return Math.abs(this * 100).toFixed(2) + '%'; };