title: Combine two object into one
body: <p>In javascript I would like to combine two objects into one. I got </p>
  
  <pre><code>{
    test: false,
    test2: false
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>{
    test2: true
  }
  </code></pre>
  
  <p>I tried to use <code>$.extend</code>, <code>$.merge</code> but all I get as an output is </p>
  
  <pre><code>{
    test2: true
  }
  </code></pre>
  
  <p>How to get output like this</p>
  
  <pre><code>{
    test: false,
    test2: true
  }
  </code></pre>
  
  <p>EDIT: Actually I have nested objects. What I need is to combine <code>a</code> and <code>b</code> as follows:</p>
  
  <pre><code>var a = { test: false, test2: { test3: false, test4: false } };
  var b = { test2: { test4: true } };
  // desired combined result:
  { test: false, test2: { test3: false, test4: true } }
  </code></pre>
  
  <p>but the actual result I get removes <code>test3</code> from the nested <code>test2</code> object.</p>