Object and Function are quite confusing

前端 未结 7 1789
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 03:47
Object instanceof Object
true
Object instanceof Function
true
Function instanceof Object
true
Function instanceof Function
true

so if Function is a

7条回答
  •  一整个雨季
    2020-12-10 04:22

    Suppose:

    <---- : links to (via .__proto__)

    <-- : has inherited property of (via .)

    Then:

    Function.prototype <---- {Object, Function}

    Object <---- Function.prototype

    Object.prototype <-- Object

    console.log(Object.prototype.constructor === Object); // true!
    

    Object.prototype does not link to anything; it doesn't have __proto__ property.

提交回复
热议问题