Object exists in two states when overwriting prototype in javascript
<p>I am trying to get my head around Object Oriented Programming in Javascript and bumped into the following issue: (This is a simplified example of what can be found in Stoyan Stefanov's book)</p>

<p>I create a constructor function to create Dog objects:</p>

<pre><code>function Dog(){
this.tail = true;
}
</code></pre>

<p>Then I instantiate an object using Dog constructor function:</p>

<pre><code>var benji = new Dog();
</code></pre>

<p>Then I assign a new property to Dog's prototype object:</p>

<pre><code>Dog.prototype.shout = 'Woof!';
</code></pre>

<p>Now, benji has access to both tail, as well as shout, as expected. All is well until I overwrite Dog's prototype:</p>

<pre><code>Dog.prototype = {paw : 4};
</code></pre>

<p>Now, benji.paw becomes undefined. My question is, shouldn't benji have access to the new prototype object as well? What's more baffling is, when I create a new instance of Dog after the prototype object was re-defined:</p>

<pre><code>var lucy = new Dog();
</code></pre>

<p>lucy.paw evaluates to 4. lucy's constructor object definition seems to be different from benji's. I am quite confused what's going on here, can someone explain how javascript's memory model for objects work? Thanks.</p>
