TEDSF Interview Skills Q&A Platform
1 like 0 dislike
5 views

Can you explain what Function.call and Function.apply do? What's the notable difference between the two?

in Web Development by Platinum (104k points) | 5 views

1 Answer

0 like 0 dislike
Best answer

both methods expect a thisArg as the first argument. This is the argument that gives the function a context; it determines the value of the JavaScript keyword 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[, ...]]]);
function.apply(thisArg[, argumentArray]);

So if you’re working with the arguments object in your JavaScript, you can call any function by using the apply method and simply pass in the existing arguments object as the array argument.

by Platinum (104k points)

Related questions

0 like 0 dislike
0 answers
0 like 0 dislike
0 answers
1 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Nov 8, 2019 in Acalytica by TEDSF Platinum (104k points) | 2 views
Welcome to TEDSF Skills Questions and Answers, a platform, where you can ask skills questions and receive answers from other members of the community. On TEDSF the youth, students, teachers, policy makers and enthusiasts can ask and answer any questions. Get help and answers to any skills-related problem including mathematics, computer science, data science, web development, physics, chemistry, digital marketing, African development and more. Help is always 100% free!

4.1k questions

1.4k answers

64 comments

29.6k users

4,058 questions
1,448 answers
64 comments
29,583 users