What is call function ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is call function ?

9th Jul 2021, 4:50 PM
Reenu Saini
Reenu Saini - avatar
2 Answers
+ 2
Are you asking about function calling if yes then suppose are working on a project so the code which u have already written for any task and in program u again want to use without overriding so u can use functions. Using function u can divide your tasks in different different modules. And u can use them by calling . Suppose if u want to do addition of two number I made a function which name is sum int sum(int ,int ); this is decleration of function int sum(int a,int b) // this is definition of function { return a+b; } Your main function { sum(4,8); // this is called function calling when u want to add two number u can call by using function name () after that semicolon }
9th Jul 2021, 6:33 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
- 1
as you didn't provide any target language, if you are asking about Function.prototype.call method (available for all functions), it allow you to call a function by providing 'this' object as first argument, followed by expected arguments of the target function... https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call similary, you can use 'apply' method (wich takes an argument array instead of each arguments comma separated), or even 'bind' wich return a new function that you can call with the arguments not provided: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
9th Jul 2021, 9:52 PM
visph
visph - avatar