title: how push and Shift are used together in this code?
body: <p>I was looking at the merge sort code and I don't understand how we push and shift together, if that is not  what happening there can some tell me</p>
  
  <pre><code> result.push(node1[0] &lt; node2[0]? node1.shift() : node2.shift());
  </code></pre>
  
  <pre><code>function mergeSort (arr) {
      if (arr.length &lt; 2) {
        return arr;
      }
  
      var mid = Math.floor(arr.length / 2);
      var subLeft = mergeSort(arr.slice(0, mid));
      var subRight = mergeSort(arr.slice(mid));
  
      return merge(subLeft, subRight);
  }
  
  function merge (node1, node2) {
      var result = [];
      while (node1.length &gt; 0 &amp;&amp; node2.length &gt; 0)
          result.push(node1[0] &lt; node2[0]? node1.shift() : node2.shift());
      return result.concat(node1.length? node1 : node2);
  }
  ``
  </code></pre>