Get Help From Experts in Data Science and Mathematics
ePortfolios |STEM Gender Equality | ZOOM | Slack | Spreading Mathematical Happiness

You can support MathsGee with your DONATION

1 like 0 dislike
31 views

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

in Data Science by Diamond (53,824 points) | 31 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 Diamond (53,824 points)

Related questions

0 like 0 dislike
1 answer
asked Nov 8, 2019 in Data Science by Tedsf Diamond (53,824 points) | 27 views
0 like 0 dislike
0 answers
0 like 0 dislike
0 answers
1 like 0 dislike
0 answers
asked Oct 5, 2020 in Mathematics by Tedsf Diamond (53,824 points) | 13 views
0 like 0 dislike
1 answer
asked Jun 26, 2020 in Data Science by Teddy Wooden (3,536 points) | 18 views
0 like 0 dislike
1 answer
asked Jun 26, 2020 in Data Science by Teddy Wooden (3,536 points) | 19 views
1 like 0 dislike
1 answer

Welcome to MathsGee Q&A Bank, Africa’s largest personalized FREE Study Help network that helps people find answers to problems and connect with experts for improved outcomes.


Get help from experts - simply ask your question


You can Support MathsGee with your DONATION

Enter your email address:

13,101 questions
10,327 answers
101 comments
11,178 users