title: Javascript concat and overwrite where element has the same id
body: <p>Is it possible to concat two arrays with objects and let the second array overwrite the first array where they have the same id:</p>
  
  <pre><code>// array 1
  [
      {id: 1, name: "foo"},
      {id: 2, name: "bar"},
      {id: 3, name: "baz"}
  ]
  
  // array 2:
  [
      {id: 1, name: "newFoo"},
      {id: 4, name: "y"},
      {id: 5, name: "z"}
  ]
  
  // out:
  [
      {id: 1, name: "newFoo"}, // overwriten by array 2
      {id: 2, name: "bar"},   // not changed (from array 1)
      {id: 3, name: "baz"},  // not changed (from array 1)
      {id: 4, name: "y"},   // added (from array 2)
      {id: 5, name: "z"}   // added (from array 2)
  ]
  </code></pre>
  
  <p>If it is possible I would like to do this without the use of third party libraries</p>