我基本上是关注 JavaScript:好的部分的例子,(第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
但是我收到了一条错误消息:
未捕获的TypeError:数学[(中间值)(中级 value)(中间值)]不是函数
对此有什么想法吗?
答案 0 :(得分:2)
应该是ceil
而不是ceiling
。