Vla*_*kov 3 javascript prototype
我认为每个原型都应该是一个对象。
为什么?
Array.isArray( Array.prototype ) // true
developer.mozilla.org没有任何解释
您认为每个原型都是一个的假设Object是不正确的。
console.log(String.prototype)
console.log(Number.prototype)
console.log(Boolean.prototype)
console.log(Array.prototype)
console.log(Object.prototype)
Run Code Online (Sandbox Code Playgroud)
输出:
String {}
Number {}
Boolean {}
[]
Object {}
Run Code Online (Sandbox Code Playgroud)
来自ECMAScript 语言规范 - 15.4.4 数组原型对象的属性(重点是我的)
Array 原型对象的 [[Prototype]] 内部属性的值是标准内置 Object 原型对象 (15.2.4)。
Array 原型对象本身就是一个数组;它的[[Class]]是“Array”,它有一个length属性(其初始值为+0)和15.4.5.1中描述的特殊[[DefineOwnProperty]]内部方法。