({}).toString.call(Number.prototype) === "[object Number]"
The Number prototype object is itself a Number object (its [[Class]] is "Number") whose value is +0.
15.7.4
为什么 Number.prototype
是一个数字会有用? (对于所有其他 [[Class]] 设置为非 Object 的内置原型(prototype)也是如此)
我选择 Number.prototype
特别是因为我可以想象 Array.prototype
和 Date.prototype
的合理遗留原因。
最佳答案
通常,Constructor.prototype
是Constructor
定义的“类型”的范例。尽管对于不可 rebase 元来说事情似乎变得棘手,尤其是当你涉及到装箱的东西时,这个范例概念仍然有意义,0
是 Number
的“范例”。
关于javascript - 为什么 Number.prototype 是一个数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10391370/