Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Every object has an internal property known as <code>[[Prototype]]</code> that carries a reference to another object, known as its prototype. When the JS interpreter is unable to find a named property in the object's own members, it looks for them in the object's prototype, then the prototype's prototype, and so on until it reaches <code>Object.prototype</code>, the lowest prototype of every object, which has no <code>[[Prototype]]</code> itself.</p> <p>The <code>[[Prototype]]</code> property is assigned the value of the constructor-function's <code>prototype</code> property by the <code>new</code> operator. So when you call <code>new Person</code> the new object receives <code>[[Prototype]]= Person.prototype</code>. When you create a function, it gets a new, empty object for its <code>prototype</code> property, but you can reassign the constructor-function's <code>.prototype</code> completely as well as writing new members to it.</p> <p>However the <code>[[Prototype]]</code> property remains the same through the life of the object; in particular, whilst adding new members to the <code>Person.prototype</code> makes them visible in all <code>Person</code> instances, assigning a new object to <code>Person.prototype</code> does not change the prototypes of existing <code>Person</code> instances.</p> <p>Normally, <code>[[Prototype]]</code> is an invisible implementation detail. But in Mozilla, the <code>[[Prototype]]</code> internal property is exposed under the public <code>__proto__</code> property. This non-standard extension has been adopted by Opera, Safari and Chrome, but not IE. In general it is considered poor form to rely on.</p> <p>In ECMAScript Fifth Edition, you will be able to fetch the <code>[[Prototype]]</code> value using the new function <code>Object.getPrototypeOf(person)</code>. Browser support is poor so far.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload