Function Call
Example of function call
Here’s an example of function call written in Javascript.
function greet(name){
console.log(`Hello ${name}!`);
greet2(name);
console.log('Getting ready to say bye...');
bye();
}
function greet2(name){
console.log(`How are you, ${name}?`);
}
function bye(){
console.log('OK bye!');
}
greet('Mina');
Steps explanation
- Memory to store the
nameMaggie andgreetfunction - console.log(
Hello Mina!); - Allocate the second memory box upon the first with:
- function
greet2 - Name: Maggie
- function
- console.log(
How are you, Mina?); - Pop off
greet2 - console.log(‘Getting ready to say bye…');
- Add
bye()to the top of the stack - console.log(‘OK bye!');
- Pop off
bye() - Return
greetfunction - Finish call stack
comments powered by Disqus