__proto__ VS. prototype in JavaScript

后端 未结 30 1991
爱一瞬间的悲伤
爱一瞬间的悲伤 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:34

    Prototype or Object.prototype is a property of an object literal. It represents the Object prototype object which you can override to add more properties or methods further along the prototype chain.

    __proto__ is an accessor property (get and set function) that exposes the internal prototype of an object thru which it is accessed.

    References:

    1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype
    2. http://www.w3schools.com/js/js_object_prototypes.asp

    3. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto

提交回复
热议问题