title: TypeError: Array.prototype.unshift called on null or undefined
body: <p>I cannot figure out why I am getting the error below from this code:</p>
  
  <pre><code>var xs = [1, 2, 3];
  var ys = [];
  _.each(xs, ys.unshift);
  console.log(ys);
  </code></pre>
  
  <p>The error is: <code>Uncaught TypeError: Array.prototype.unshift called on null or undefined</code>.</p>
  
  <p>I am using underscore.js. I tried</p>
  
  <pre><code>_.each(xs, _.bind(Array.prototype.unshift, xs));
  </code></pre>
  
  <p>but this resulted in something I did not expect at all:</p>
  
  <pre><code>[3, 2, Array[3], 2, 1, Array[3], 1, 0, Array[3]]
  </code></pre>
  
  <p>where the sub-arrays are actually what I wanted: <code>[1, 2, 3]</code>.</p>
  
  <p>the only variation that worked is:</p>
  
  <pre><code>_.each(xs, function (x) { ys.unshift(x); });
  </code></pre>
  
  <p>But I wanted to pretend that I am using a functional language and just supply the function to <code>each</code>...</p>
  
  <p>Please help. What am I doing wrong?</p>