Skip to content

Commit 85f7cae

Browse files
authored
Update README.md
1 parent 4cf0012 commit 85f7cae

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ Browser gives us a **Web API** :lollipop: (DOM, setTimeout, HTTP requests, and s
77
## <a name="eventLoop"></a>📖 Event loop:
88
&emsp;The **event loop** is the main mechanism used by JavaScript and Node.js to manage asynchronous operations. It's a continuously running process that checks the call stack for any pending function calls and queues up any asynchronous operations that are ready to run.
99

10+
&emsp;The **call stack** (_part of the JS engine, this isn’t browser specific_) is a data structure that keeps track of the currently executing function calls.
11+
> _Whenever function is called, it's added to top of call stack :waffle:, and when function returns, it's removed from the top of stack.\
12+
> Meaning that it’s first in, last out._
13+
14+
&emsp;When asynchronous operation is queued up, it's added to either microtask queue or macrotask queue, depending on type of operation.
15+
> _Microtasks are higher priority than macrotasks, and will always be executed before any macrotasks that are currently queued up._
16+
1017

1118

1219
&emsp;The **event loop** executes tasks in the following order:<br>
@@ -17,15 +24,6 @@ Browser gives us a **Web API** :lollipop: (DOM, setTimeout, HTTP requests, and s
1724
5. **macrotask** queue (_ ...setImmediate callback _)
1825
6. **macrotask** queue (_ ...setTimeout(callback, n), setInterval callback _)
1926

20-
&emsp;When we invoke a function, it gets added to the **call stack** :waffle: (_part of the JS engine, this isn’t browser specific_) - meaning that it’s first in, last out. When a function returns a value, it gets popped off the stack.<br>
21-
22-
23-
24-
25-
26-
27-
28-
2927

3028
- - -
3129

0 commit comments

Comments
 (0)