title: How to replace an object in object array in javascript (lodash)
body: <p>I have following object array: </p>
  
  <pre><code>var arr = [
    {
      id    : "a1",
      guid  : "sdfsfd",
      ...
      value : "abc",
      status: false
    },
    {
      id    : "a2",
      guid  : "sdfsfd",
      ...
      value : "def",
      status: true
    },
    ...
  ]
  </code></pre>
  
  <p>I have this object: </p>
  
  <pre><code>var obj = {
    id      : "a1",
    guid    : "sdfsfd",
    ...
    value   : "xyz",
    status  :  true
  }
  </code></pre>
  
  <p>I need to replace the object in the array with this object where the "id" is same. So the resulting array will be: </p>
  
  <pre><code>var arr = [
    {
      id    : "a1",
      guid  : "sdfsfd",
      ...
      value : "xyz",
      status: true
    },
    {
      id    : "a2",
      guid  : "sdfsfd",
      ...
      value : "def",
      status: true
    },
    ...
  ]
  </code></pre>
  
  <p>Additionally I need to add this object to the array if an object with that id doesn't  exists. </p>
  
  <p>How to achieve this using minimal <a href="https://lodash.com/docs/4.17.4" rel="noreferrer">lodash</a> code? 
  Looking for something like </p>
  
  <pre><code>arr = _.merge_by_key(arr,obj,"id");
  </code></pre>