Extending/overriding in JavaScript?
<p>I want to write a small game using JavaScript and <code>&lt;canvas&gt;</code> but first I want to nail the "correct" or at least common approach to working with Objects.</p>

<p>One topic I am having trouble understanding in particular is how I could implement <code>overriding</code> of method.</p>

<p>When I create an Object, I may have this:</p>

<pre><code>function MyObject()
{
    var base = {};

    base.i = 0;
    base.update = function()
    {
        base.i ++;
    }

   return base;
}
</code></pre>

<p>Then when I create another Object that should start with the same members, I use this:</p>

<pre><code>function AnotherObject()
{
    var base = new MyObject();

    base.j = 0;

    return base;
}
</code></pre>

<p>I want to add more content to <code>AnotherObject.update()</code> while still running the logic I have in <code>MyObject.update()</code>, but when I do this within <code>AnotherObject()</code>:</p>

<pre><code>base.update = function()
{
    j ++;
}
</code></pre>

<p>Then I of course lose the logic I added in <code>MyObject.update()</code>.</p>

<p>How can I write <code>AnotherObject.update()</code> so that it also calls the original <code>update()</code> method defined by <code>MyObject</code>?</p>
