Stack size and javascript callbacks

Do Asynchronous Callback Operations Increase Stack Size? I don't have enough knowledge of javascript translators or the right tools to figure this out. My goto tool is a firebug console, and it shows that the stack size is not increasing, but I may look at it incorrectly. So does anyone know?

+3
source share
2 answers

An asynchronous callback, like an event callback, is triggered one after another through an event loop. It is not called from one call stack of a function that places it in an event loop, since each function of the loop ends before the next one is called. No, they do not increase the size of the stack.

+5
source

I believe that all javascript engines in modern browsers are single-threaded, which means that the callback cannot happen until the current execution path ends. This will mean that the stack is completely unwound and the callback will occur (essentially) with the new stack.

The stack size will only increase when a function is called or a local variable is declared. The stack will decrease again when you leave the scope that caused the increase.

, .

, , javascript . (, ), , .

+4

Source: https://habr.com/ru/post/1773445/


All Articles