獲取某個對象的原型Object.getPrototypeOf(obj) Object.getPrototypeOf({})==Object.prototypetrue var a = new Object();Object.getPrototypeOf(a)==Object.prototypetru ...
獲取某個對象的原型
Object.getPrototypeOf(obj)
Object.getPrototypeOf({})==Object.prototype
true
var a = new Object();
Object.getPrototypeOf(a)==Object.prototype
true
Object.getPrototypeOf(Object)==Function.prototype
true
註意:
Object是Object類的構造函數,Object.getPrototypeOf(Object)是把Object這個構造函數當做對象來看待,獲取對象的原型
即是把Object這個構造函數當做函數對象來看待,獲取函數對象的原型,等同於Function.prototype