function check(x) { return x = isNaN(x) ? 0 : x-0; } Number.prototype.add = function (x) { x = check(x); return this + x } Number.prototype.minus = function (x) { x=check(x); return this - x } console.log((5).add(3).minus(2))