Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>On your comments:</p> <pre><code>&gt; //Object.create equals an anonymous function that accepts one parameter, 'o'. </code></pre> <p>Better to say that a function is assigned to the <code>create</code> property of <code>Object</code>. All functions can be considered anonymous, just that some are assigned to named properties or variables, others aren't.</p> <pre><code>&gt; //Create a new function called 'F' which is just an empty object. </code></pre> <p>Declare a function. Yes, it's an object too.</p> <pre><code>&gt; F.prototype = o; &gt; //the prototype of the 'F' function should point to the &gt; //parameter of the anonymous function. </code></pre> <p>A reference to <code>o</code> is assigned to <code>F.prototype</code> is a bit shorter to write.</p> <pre><code>&gt; //create a new constructor function based off of the 'F' function. </code></pre> <p>No, should be "Return an instance of F". So the returned object has an internal <code>[[Prototype]]</code> that references the object passed to the function. The messy part is that a useless F function had to be created to perform the trick, and the returned object's constructor will not have a useful value as it references the empty <code>F</code>. </p> <p>Not that the constructor property is very reliable or particularly useful normally anyway.</p> <blockquote> <p>This way, the prototype of the 'stooge' object can't be overwritten when we augment stuff to 'another_stooge'. No need to reset the 'stooge' prototype using 'constructor'.</p> </blockquote> <p>That's a strange statement. *another_stooge* has <code>stooge</code> as it's private <code>[[Prototype]]</code>, it does not inherit from <code>stooge.prototype</code> but from <code>stooge.[[Prototype]]</code>.</p> <p>If you want <code>another_stooge</code> to inherit from <code>stooge.prototype</code>, use <code>Object.create(stooge.prototype)</code> or <code>Object.create(new stooge())</code>, the former is probably more suitable.</p> <p>I hope that all makes sense.</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. 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