heap. where memory allocation happens
call stack: is’t a data structure which records where in the program we are
Single thread => one call stack => one thing at a time
NB (12′ 23″) The JS Runtime is single thread but there are WebAPIs which behave like threads and are aware of concurrency
NB In the browser there is WebAPIs, in node there is a software layer builded in C++
Event loop: look at the stack and look at the task queue, if the stack is empty it takes the first thing on the queue and pushes it on the stack
callback queue
RangeError: Maximum call stack size exceeded
Blowing the stack => happens when functions in the stack have no return and the stack get filled!
Ex.: a function calling itself!
Ex. Asynchronous ForEach
In this example can be see the synchronous native forEach vs a coded asynchronous asyncForEach
0 commenti