What is the meaning of “callback.call( value, i, value )” in jQuery’s each method?

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)