[Javascript] Call Stack

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Javascript] Call Stack相关的知识,希望对你有一定的参考价值。

Every time when a function run it will be push into the call stack and put on the top,  you can think call stack is something like a heap... Javascirpt has only one call stack. 

技术分享

 

In the picture, main() get call first, so put into the call stack;

second, printSquare(), put into the call stack;

third, inside printSquare() call suqare() function, so put into call stack;

fourth, inside square() function, multiply() function get call....

 

--------------------------

 

When function return or done, the function will be poped up from the call stack:

技术分享

So, multiply() function ruturned, so pop up from the call stack;

then square();

then inside printSquare() function, console.log() funciton get call, so need to push intot the call stack.

After that, console.log() pop up;

printSquare() pop up;

finally main() pop up;

 

You can see the call stack from the Chrome dev tool‘s source tab when you use ‘debugger‘.

 

以上是关于[Javascript] Call Stack的主要内容,如果未能解决你的问题,请参考以下文章

RangeError: Maximum call stack size exceeded

RangeError: Maximum call stack size exceeded

RangeError: Maximum call stack size exceeded

RangeError: Maximum call stack size exceeded

函数调用栈(Call Stack)

函数调用栈(Call Stack)