I read some article and it said the following 2 line are doing the same thing.
fn.call(thisValue);
Function.prototype.call.call(fn, thisValue);
For line 1, my understanding is that every function object in Javascript do have a the method call
inherited from the Function.prototype
and what call
method does is to have the this
keyword inside the function definition of fn
to be thisValue
(the first parameter I passed in the call method. fn
is a function so what I am doing in fn.call(thisValue)
is just invoking fn
and set the this
keyword inside the function to be thisValue
.
But For line 2, I don't get it. Can someone help to explain it what the hack the line 2 is doing.