In Javascript, Function.call()
can call Function
given a this
value and zero or more arguments.
Function.call
its
Short answer: The error message is very misleading. It is the same error message you get when you do
(undefined)();
Longer answer:
The second .call()
is being invoked with a this
of Function.call
.
Calling it with no parameters causes it to call this
with undefined
as the this
value.
Therefore, you're really doing
Function.call.call(undefined)
which means you're (metaphorically) doing
undefined.call()
which is really just
undefined()
Passing nothing (or undefined
) to the this
parameter of Function.call.call()
is essentially negating the this
context of the first Function.call()
(which would be just Function
itself), causing .call()
to be invoked on undefined
.
This yields the error message that is produced: undefined is not a function
.