__proto__ VS. prototype in JavaScript

后端 未结 30 1909
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-21 06:14

This figure again shows that every object has a prototype. Constructor function Foo also has its own __proto__ which is Function.prototype, a

30条回答
  •  爱一瞬间的悲伤
    2020-11-21 06:54

    __proto__ is the actual object that is used in the lookup chain to resolve methods, etc. prototype is the object that is used to build __proto__ when you create an object with new:

    ( new Foo ).__proto__ === Foo.prototype;
    ( new Foo ).prototype === undefined;
    

提交回复
热议问题