title: Performing Set calculations in javascript array
body: <p>I have 2 arrays lets say:</p>
  
  <pre><code>A = [1,2,3,4,5] and B = [1,2,3,6,7]
  </code></pre>
  
  <p>and I'd like to perform the following 'set calculations':</p>
  
  <pre><code>C = (A ∩ B)
  D = A - (A ∩ B)
  E = B - (A ∩ B)
  </code></pre>
  
  <p>Essentially:</p>
  
  <pre><code>C = [1,2,3]
  D = [4,5]
  E = [6,7]
  </code></pre>
  
  <p>Is there a smart way to do this or am I going to have to cross check each array member with loops and ifs? I cannot use an external library (like math.js or w/e).</p>
  
  <p>Thanks in advance.</p>