Number.prototype.toFixed = function(fractionDigits) { var m = Math.pow(10,fractionDigits); return Math.round(this*m,0)/m; } Example: (12.3456789).toFixed(5); will return 12.34568