最佳答案
您假设每个原型(prototype)都是一个 Object
是不正确的。
console.log(String.prototype)
console.log(Number.prototype)
console.log(Boolean.prototype)
console.log(Array.prototype)
console.log(Object.prototype)
输出:
String {}
Number {}
Boolean {}
[]
Object {}
来自ECMAScript Language Specification - 15.4.4 Properties of the Array Prototype Object (强调我的)
The value of the [[Prototype]] internal property of the Array prototype object is the standard built-in Object prototype object (15.2.4).
The Array prototype object is itself an array; its [[Class]] is "Array", and it has a length property (whose initial value is +0) and the special [[DefineOwnProperty]] internal method described in 15.4.5.1.
关于javascript - 为什么 Array.prototype 是一个数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23652338/