i want to know the concept for call and apply uses, Is there any execution wise difference between them. why java script introduced call over apply?
where and when we can use call and apply in javascript?
i want to know the concept for call and apply uses, Is there any execution wise difference between them. why java script introduced call over apply?
where and when we can use call and apply in javascript?
call
is like bind
, except that the function is immediatly executed.
apply
is like call
, except you pass the arguments to the function as an array.
myFunc.call(this, arg1, arg2, ..., argn);
is equivalent to
myFunc.bind(this, arg1, arg2, ..., argn)();
which is equivalent to
myFunc.apply(this, [arg1, arg2, ..., argn]);