Differentiate between .call and .apply.
.call | .apply |
---|---|
.call is used to invoke the functions, and the first parameter will become the value of this within the function created by the developer. | .apply is also used to invoke the functions but it takes an array of arguments. This array works as the next argument and the function works this way. |
.call is used to call the method which takes the owner object as its argument. | .apply method is used to write methods. These methods can be used on several objects. |
It accepts two parameters namely objectInstance and arguments | It accepts two parameters namely objectInstance and arrayofArguments |
.call takes several arguments separated by commas. | .apply takes several arguments with the help of an array of arguments. |
BY Best Interview Question ON 06 Oct 2019