Javascript Number tryParseToFixed(decimalPlaces)
Number.prototype.tryParseToFixed = function(decimalPlaces) { if(!decimalPlaces) decimalPlaces = 0; if (isNaN(this)) { throw this + ' could not be converted to a Number.'; } return parseFloat(this).toFixed(decimalPlaces); }