title: How to join two arrays conditionally
body: <p>I have two arrays that I want to join conditionally:</p>
  
  <pre><code>aData = [ { id: 1, title: `bla`}, { id: 2, title: `la`}, { id: 3, title: `lala`} ]
  bData = [ { id: 1, description: `bla`} ]
  </code></pre>
  
  <p>In the first case I want to be able to get only matching result (<code>aData+bData</code>) with merged properties</p>
  
  <pre><code>matchingIdsResult = [ { id: 1, title: `bla`, description: `bla` } ]
  </code></pre>
  
  <p>IN the second case I want the unmatching result - just objects from <code>aData</code> with ids that didn't ocour in <code>bData</code>:</p>
  
  <pre><code>unmathingIdsResult = [ { id: 2, title: `la`}, { id: 3, title: `lala`} ]
  </code></pre>
  
  <p>I was playing with <code>.map</code> and <code>.reduce</code> and achieve this so far:</p>
  
  <pre><code>const data: any = aData.concat(bData).reduce((acc, x) =&gt; {
      acc[x.id] = Object.assign(acc[x.id] || {}, x);
      return acc;
  }, {});
  </code></pre>
  
  <p>However in that case I do get all <code>aData</code> objects merged with matching <code>bData</code> properties so far which is not really what I want. </p>