Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>the_drow:</p> <p>I left a comment above about calling the super constructor twice with your solution - but feel a bit bad about leaving you hanging on the implementation of inheritPrototype. First of all, credit to Nicholas Zakas as this is me paraphrasing his book Professional JavaScript for Web Developers, 2nd Ed (page 181):</p> <pre><code>function inheritPrototype(sub,sup) { var proto = object(sup.prototype);// you'll need an object create method ;) proto.constructor = sub; sub.prototype = proto; } </code></pre> <p>Now replace your:</p> <pre><code>StreetGridView.prototype = new GridView(); </code></pre> <p>with,</p> <pre><code>StreetGridView.prototype = inheritPrototype(StreetGridView,GridView); </code></pre> <p>and you've only called your GridView constructor once! But you'll notice the object method. You'll need something like:</p> <pre><code>function object(o) { function F(){}; F.prototype = o; return new F(); } </code></pre> <p>If you've read any Douglas Crockford you've seen this one!</p> <p><strong>Shameless Plug:</strong> <em>This stuff is hard to grok and is the exact reason I'm doing an essay on TDD JavaScript and the whole second part has a bunch of unit tests of inheritance patterns. I'm specifically examining the Zakas and Crockford books on object creation and inheritance. You don't have to read my essay (it's currently in Open Office .odt format), but you could do a lot worse than to just download my code and read it in 2 minutes! Here's the link:</em> <a href="http://github.com/roblevintennis/Testing-and-Debugging-JavaScript" rel="nofollow noreferrer">My Free Book</a></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.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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