Number.prototype.round = function(n) { var n = Math.pow(10, n || 0); return Math.round(this * n) / n; } alert(11.22.round()) alert(11.22.round(1)) alert(11.22.round(-1))