Heim > Fragen und Antworten > Hauptteil
Object.getPrototypeOf(Object)
[Function: Empty]
Object.prototype
{}
两者都是获取Object的prototype,但为什么结果不一样呢?
PHPz2017-04-10 14:41:42
呵呵呵呵你混淆了兩個概念。
The
Object.getPrototypeOf()
method returns the prototype (i.e. the value of the internal [[Prototype]] property) of the specified object.
The
Function.prototype
property represents the Function prototype object.
Function objects inherit fromFunction.prototype
.Function.prototype
cannot be modified.
Object.prototype === Object.getPrototypeOf(new Object());
Object
本身是一個 函數,Object.prototype
不是 Object
這一對象的原型,而是 Obejct
這一函數的 函數原型,也就是 new Object()
的原型。
而 Object.getPrototypeOf(Object)
是把 Object
這一函數看作對象,返回的是 函數對象 的 原型,也就是 Function.prototype
即 function Empty() {}
了。