+ 4
What is the difference between .call() and .apply()?
They seem to be very similar. What is difference between these two methods and which one is better to use?
6 Answers
+ 4
Both can be called on functions, which they run in the context of the first argument.
In call the subsequent arguments are passed in to the function as they are.
The limitations of call become apparent when you want to write code that doesn't (or shouldn't) know the number of arguments.
Apply expects the second argument to be an array that it unpacks as arguments for the called function.
+ 1
thanks^^
0
hello
0
hi



