title: How do I calculate runtime complexity of the following JavaScript algorithm?
body: <p>Below is a simple program to merge 2 arrays. I have used two different ways to solve this problem. How do I calculate runtime complexity, if possible space complexity too, of both these versions? Thanks in advance!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let A = [1, 2, 3];
  let B = [2, 3 , 4, 5];
  
  // VERSION: 1
  //let C = A.concat(B.filter( item =&gt; {return A.indexOf(item) &lt; 0;} ));
  
  // VERSION: 2
  let C = [...new Set([...A,...B])];
  
  // result:
  console.log(C);</code></pre>
  </div>
  </div>
  </p>