You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/site/pages/en/learn/asynchronous-work/understanding-processnexttick.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,25 +31,25 @@ Use `nextTick()` when you want to make sure that in the next event loop iteratio
31
31
console.log('Hello => number 1');
32
32
33
33
setImmediate(() => {
34
-
console.log('Running before the timeout => number 3');
34
+
console.log('Running at order 3 or 4, setImmediate');
35
35
});
36
36
37
37
setTimeout(() => {
38
-
console.log('The timeout running last => number 4');
38
+
console.log('Running at order 3 or 4, setTimeout');
39
39
}, 0);
40
40
41
41
process.nextTick(() => {
42
42
console.log('Running at next tick => number 2');
43
43
});
44
44
```
45
45
46
-
#### Example output:
46
+
#### Example output(possible):
47
47
48
48
```bash
49
49
Hello => number 1
50
50
Running at next tick => number 2
51
-
Running before the timeout => number 3
52
-
The timeout running last => number 4
51
+
Running at order 3 or 4, setImmediate
52
+
Running at order 3 or 4, setTimeout
53
53
```
54
54
55
-
The exact output may differ from run to run.
55
+
The exact output may differ from run to run.[setImmediate vs setTimeout](https://nodejs.org/en/learn/asynchronous-work/event-loop-timers-and-nexttick#setimmediate-vs-settimeout) explain the reason.
0 commit comments