title: Merge two object literals in javascript
body: <p>I have two object literals:</p>
  
  <pre><code>var animal = {
      eat: function() {
          console.log("eating...");
      }
  }
  
  var dog = {
      eat: "this has to be replaced when merged",
      nrOfLegs: 4
  }
  </code></pre>
  
  <p>Need a merging function like this:</p>
  
  <pre><code>dog = someMergingFunction(animal, dog);
  </code></pre>
  
  <p>That produces:</p>
  
  <pre><code>{
      eat: function() {
          console.log("eating...");
      },
      nrOfLegs: 4
  }
  </code></pre>
  
  <p>One of the object literals has to replace identical properties.</p>
  
  <p>How do I do this in Javascript?</p>