What is the difference between using call
and apply
to invoke a function?
var func = function() {
alert(\'hello!\');
};
>
Both call and apply the same way. It calls immediately when we use call and apply.
Both call and apply takes "this" parameter as the first argument and the second argument only differs.
the call takes the arguments of the functions as a list (comma ) Apply takes the arguments of the functions as an array.
You can find the complete difference between bind, call, and apply in the bellow youtube video.
https://www.youtube.com/watch?v=G-EfxnG0DtY&t=180s