jvascript
function delay(duration = 0) {
return new Promise((resolve) => {
setTimeout(resolve, duration)
})
};
delay().then(()=> {
console.log(1);
Promise.resolve()
.then(() => {
console.log(2);
})
})
Promise.resolve()
.then(delay)
.then(() => {
console.log(3);
})
console.log(4);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

