2

.map() on arrays expects a function as parameter. This works:

[[1]].map(function(array) {
  return Array.prototype.slice.call(array);
});

typeof Array.prototype.slice.call returns "function".

So why doesn't the following call work?

[[1]].map(Array.prototype.slice.call);

It throws an error:

Uncaught TypeError: [[1]].map is not a function
    at Array.map (native)
    at <anonymous>:2:7
    at Object.InjectedScript._evaluateOn (<anonymous>:895:140)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34)
    at Object.InjectedScript.evaluate (<anonymous>:694:21)
Amberlamps
  • 39,180
  • 5
  • 43
  • 53
  • 3
    Issuing .call against a function does not return you function. It invokes the function with a specified value of 'this'. – sma Jun 03 '15 at 13:38
  • If I call a variable with `()`, it is a function to me. `typeof` also returns `"function"`. This also does not explain the error message. – Amberlamps Jun 03 '15 at 13:42

0 Answers0