title: Confused about array.shift() - example from Secrets of the JS Ninja
body: <p>I'm reading the book Secrets of the JavaScript Ninja and I'm stuck on some syntax within a code example. If you have the book, the code can be found on page 17 but a sample of it is below.</p>
  
  <pre><code>function runTest() {
    if (!paused &amp;&amp; queue.length) {
      queue.shift()();
      if(!paused) {
        resume();
      }
    }
  }
  </code></pre>
  
  <p>Can anybody explain what's going on in line 3? What does <code>queue.shift()();</code> do? I've looked through the documentation on MDN and I've played with it a little in JSFiddle but I can't seem to figure it out. I suspected it may remove the first two elements from an array but that didn't work and the code example doesn't run without the second set of <code>()</code>.</p>
  
  <p>If more code is needed to make sense of this, please let me know and I can add more.</p>