Reputation: 23
I was basically following the example on JavaScript: The Good Parts, says (on page 49):
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
Number.method('integer', function () {
return Math[this < 0 ? 'ceiling' : 'floor'](this);
});
document.writeln((-10 / 3).integer()); // -3
But I got an error message:
Uncaught TypeError: Math[(intermediate value)(intermediate value)(intermediate value)] is not a function
Any idea on this?
Upvotes: 2
Views: 64