What’s the difference between function.call and function.apply?
arguments object. It was called
apply in that article I hadn’t talked about the difference.
Well it’s actually quite simple. First of all, both methods expect a
this inside the function that is called or applied. The single difference is that the
call method requires that arguments are specified separately; the
apply method takes them as an array. It’s clearer if you see the syntax:
function.call(thisArg[, argument1[, argument2[, ...]]]);
So if you’re working with the
arguments object as the array argument.
Hope that’s useful to you!
Feature image by Sudhamshu. Can you work out the significance?