Javascript extending an object question
<p>I have the following code:</p>

<pre><code>this.myObject = {
   key1: "val1",
   key2: "val2"
}

this.aMethod = function (newObject) {
    ...
</code></pre>

<p>Here I want a new object (probably that inherits from <code>this.myObject</code>) that contains everything in <code>this.myObject</code> <em>plus</em> whatever is in <code>newObject</code> also, fields in <code>newObject</code> should override already existing fields in <code>this.myObject</code></p>

<p>How do I do this?</p>

<p>This idea is that <code>this.myObject</code> provides some default values - but the user of the method can override these values.  I'm open to criticisms of this overall "pattern" as well.  Thanks.</p>
