Skip to main content

Command Palette

Search for a command to run...

Explain the steps how “Control Flow” controls the functions calls?

Updated
1 min read
Explain the steps how “Control Flow” controls the
functions calls?
R

Full Stack Developer with a passion for building web applications. PHP, Node.js, Laravel, MySQL, MongoDB. Love collaborating & making a difference

  • When a script calls a function, the interpreter adds it to the call stack and then starts carrying out the function.

  • Any functions that are called by that function are added to the call stack further up, and run where their calls are reached.

  • When the current function is finished, the interpreter takes it off the stack and resumes execution where it left off in the last code listing.

  • If the stack takes up more space than it was assigned, a "stack overflow" error is thrown.

Sources: Call stack - MDN Web Docs Glossary: Definitions of Web-related terms | MDN. (2022, September 21). https://developer.mozilla.org/en-US/docs/Glossary/Call_stack

More from this blog

R

Raja Muhammad Asher - Senior Software Engineer - Full Stack Developer

157 posts

Full Stack Developer with a passion for building web applications. PHP, Node.js, Laravel, ExpressJS, MySQL, MongoDB. Love collaborating & making a difference