What is the difference between call and apply?

Posted by Jessica Taylor | Updated on

What is the difference between call and apply? Difference between call() and apply() method: The only difference is call() method takes the arguments separated by comma while apply() method takes the array of arguments.

The difference is that apply lets you invoke the function with arguments as an array; call requires the parameters be listed explicitly. A useful mnemonic is “A for array and C for comma.”

There is also, as of ES6, the possibility to spread the array for use with the call function, you can see the compatibilities here. Below is a sample example:

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers