title: compare 2 objects and adjust the second one based on first in a smarter way
body: <p>I have a function with 2 objects .It is supposed to compare the first one with second and modify the second one based on first one.
  Remove all objects not present in first object but is present in second object, from second object
  Add all objects present in first, but not in second, to second object</p>
  <p>I need to do it this way because the ordering present in object2 is important and cannot be touched.</p>
  <p>Can I do this in a smarter way, maybe using lodash?</p>
  <pre><code>        const object1 = nextProps
          var object2 = [...this.state.changes]
          object1.map(source =&gt;
              object2.find(item =&gt; source.id === item.id)
              ? null
              : object2.push(source)
          )
          const objectCopy = [...object2]
          objectCopy.map((item, index) =&gt; object1.find(source =&gt; source.id === item.id)
              ? null
              : object2.splice(index, 1, null))
          object2 = object2.filter(item =&gt; item !== null)
          return object2
  </code></pre>