Skip to content

Commit 6223823

Browse files
authored
Update README.md
1 parent 2b5a154 commit 6223823

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,22 @@ console.log(f2()); // undefined
142142
> }
143143
> }
144144
> ```
145+
146+
---
147+
148+
## :link: setTimeout order
149+
150+
```javascript
151+
function orders() {
152+
console.log(1);
153+
setTimeout(() => console.log(2), 1000);
154+
setTimeout(() => console.log(3), 0);
155+
console.log(4);
156+
}
157+
158+
orders() // 1, 4, 3, 2
159+
```
160+
161+
## Explanation
162+
163+
> The console.log executes first before the async functions (setTimout function) and then the async functions executes appending on who is the faster.

0 commit comments

Comments
 (0)