Miklos 是对的,但更简单地说:
Object.__proto__ == Function
意味着它Object
本身是一个函数,因为它是构造函数。这并不意味着继承自的对象Object
将继承Function
。一个对象继承了一个构造函数的.prototype
,而不是它的.__proto__
换句话说
function Car (){}
inst = new Car ();
// inst inherits from Car.prototype
// inst.__proto__ == Car.prototype;
// Car inherits from Function.prototype because it is a function
// Car.__proto__ == Function.prototype;
但这并不意味着inst
继承自,Function.prototype
你不能调用它。apply
call
// This means that Everything that inherits from function will
console.log(`Function.prototype`) === function Empty() {}
另一个转折
// This means that the constructor function (Object)
// inherits from `Function.prototype` That is, you can use call and apply,
// And at a lower language level, you can use () and new on it.
Object instanceof Function // true
// It doesn't mean that instances created from Object inherit
// from Function.prototype (can't use call/apply)
(new Object()) instanceOf Function ? // false
(new Object()).apply === undefined ? // true
// This means that functions themselves are objects, everything is an object
// They have properties like hasOwnProperty and isPrototypeOf
// Not that everything that inherits from Object.prototype will also inherit
// From Function.prototype
Function instanceof Object // of course true