@@ -29,3 +29,37 @@ Macrotask
29
29
settimeout , click etc
30
30
31
31
Mutation Observer
32
+
33
+
34
+ ## Priorty
35
+
36
+ # JavaScript Execution Priority Order
37
+
38
+ ## 1️⃣ Call Stack (Synchronous Code) - ** Highest Priority**
39
+ - Executes ** immediately** in order.
40
+ - Examples:
41
+ - ` console.log("Hi") `
42
+ - Variable declarations
43
+ - Function executions
44
+
45
+ ## 2️⃣ Micro-task Queue (Higher Priority than Macro-task)
46
+ - ** Promises (` .then() ` , ` .catch() ` , ` .finally() ` )**
47
+ - ** Async/Await (` await ` resumes here)**
48
+ - ** MutationObserver (rarely used)**
49
+ - These tasks execute ** immediately after synchronous code finishes** .
50
+ - Examples:
51
+ ``` js
52
+ Promise .resolve ().then (() => console .log (" Microtask" ));
53
+
54
+ ## 3 ️⃣ Macro- tasks (setTimeout, setInterval, setImmediate, I / O )
55
+ - setTimeout, setInterval, setImmediate (Node .js )
56
+ - I / O tasks (like reading files in Node .js )
57
+ - UI rendering tasks (in browsers)
58
+ - Runs after all micro- tasks are completed.
59
+
60
+ ## 4 ️⃣ Render tasks (UI updates, reflows, repaints)
61
+ UI updates, painting, and rendering.
62
+ Executed after Micro- tasks and Macro- tasks.
63
+ Examples:
64
+ DOM updates after JavaScript execution
65
+ CSS animations, reflows, repaints
0 commit comments