title: Overwrite/Merge two objects in JavaScript/jQuery
body: <p>I want my user input to overwrite the defaults, but have the defaults fill in the blank if the data is not there. Like so:</p>
  
  <pre><code>var userInput={
      name:"Pat",
      color: "green"
  }
  var defaults={
      name:"Trevor",
      color: "blue",
      state: "washington"
  }
  var finalObject=mergeObjects(userInput,defaults);
  //Should produce:
  {
      name:"Pat",
      color: "green",
      state: "washington"
  }
  </code></pre>
  
  <p>Is this kind of merging/overwriting possible with jQuery? I did see <a href="https://stackoverflow.com/questions/1584370/how-to-merge-two-arrays-in-javascript">this question</a> but it works with <strong>arrays</strong> and does <strong>not</strong> overwrite like I need it to. </p>
  
  <p>Any ideas?</p>