title: Uncaught TypeError: .unshift is not a function
body: <p>I have a quite trivial piece of code that has me stuck. </p>
  
  <p>With the following piece of code I'm trying to add a value to the start of the array which is the current first value minus 100.</p>
  
  <pre><code>var slideHeights = null;
  // ... other stuff, nothing is done to slideHeights
  function updateHeights() {
      slideHeights = $('*[data-anchor]').map(function(i, item) {
          return Math.floor($(item).offset().top);
      }); // [2026, 2975, 3924, 4873, 5822, 6771, 7720, 8669, 9618]
      slideHeights.unshift(slideHeights[0] - 100);
      slideHeights.push(slideHeights[9] + 100);
  }
  </code></pre>
  
  <p>And I'm receiving the error </p>
  
  <blockquote>
    <p>Uncaught TypeError: slideHeights.unshift is not a function</p>
  </blockquote>
  
  <p>If I comment the <code>.unshift</code> and correct the index in the <code>.push</code> all works fine and the 9th element is added correctly.</p>
  
  <p>I even tried separating the value, but with no luck:</p>
  
  <pre><code>var x = slideHeights[0] - 100;
  slideHeights.unshift(x);
  </code></pre>
  
  <p>I'm really stumped on this, it must be a trivial problem I'm not seeing. </p>
  
  <p>Any ideas?
  Thanks in advance for your replies.
  Have a nice day! :)</p>