title: How to merge two Javascript objects by key value
body: <p>I need to merge two Javascript objects by its key value mapping.</p>
  
  <p>Here is my first Javascript object</p>
  
  <pre><code>var json1= [
      { ID: 1, limit: 5, name: "foo" }, 
      { ID: 2, limit: 9, name: "dog" }
  
     ];
  </code></pre>
  
  <p>Here is my second Javascript object</p>
  
  <pre><code> var json2 = [
          { ID: 2, validate: false, LastRunTime: "February" }, 
          { ID: 1, validate: true, LastRunTime: "January" }
      ];
   $.extend(true, {}, json1, json2);
  </code></pre>
  
  <p>this gives me the resultant Javascript like this </p>
  
  <pre><code>[
      {
          {
              ID: 2,
              LastRunTime: "February",
              limit: 5,
              name: "foo",
              validate: false
          },
          {
              ID: 1,
              LastRunTime: "January",
              limit: 9,
              name: "dog",
              validate: true
          }
      }
  ]
  </code></pre>
  
  <p>but I am looking for the code that map ID as a key and then merge the Javascript objects like this irrespective of their order in array.</p>
  
  <pre><code>[
      {
          {
              ID: 1,
              LastRunTime: "January",
              limit: 5,
              name: "foo",
              validate: true
          },
          {
              ID: 2,
              LastRunTime: "February",
              limit: 9,
              name: "dog",
              validate: false
          }
      }
  ]
  </code></pre>