The call
method exists on all functions in Javascript. It allows you to call the function and in doing so set the value of this
within that function.
function myFunc() {
console.log(this);
}
myFunc.call(document.body);
In this example, this
within myFunc
will be document.body
.
The first parameter of call
is the value to be set as this
; subsequent parameters are passed on to the function as normal parameters. So, in your example:
callback.call( value, i, value )
this is equivalent to
callback(i, value)
except that, within the callback, this
is now also set to value
.