-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
91 lines (86 loc) · 1.98 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Promise.resolve().then(() => {
// console.log(0);
// return Promise.resolve(4);
// }).then((res) => {
// console.log(res)
// })
// Promise.resolve(Promise.resolve(4)).then((res) => {
// console.log(0);
// // return 4;
// return new Promise((resolve) => { resolve(4) });
// }).then((res) => {
// console.log('res=====', res)
// }, err => {
// console.log('err====', err)
// })
// new Promise((resolve, reject) => {
// console.log(0)
// resolve(Promise.resolve(Promise.resolve(Promise.resolve(4))))
// }).then(res => {
// console.log(res)
// })
// Promise.resolve().then(() => {
// console.log(1);
// }).then(() => {
// console.log(2);
// }).then(() => {
// console.log(3);
// }).then(() => {
// console.log(5);
// }).then(() => {
// console.log(6);
// })
// const p1 = new Promise((resolve, reject) => {
// console.log(1)
// resolve(4)
// })
// const p2 = p1.then(function p1Fullfilled(res){
// console.log(2)
// const p21 = new Promise((resolve, reject) => {
// console.log('2-1')
// resolve('2-1')
// })
// return p21
// })
// const p3 = p2.then(function p2Fullfillled(res){
// console.log(3)
// })
// const p10 = new Promise((resolve, reject) => {
// console.log(10)
// resolve(4)
// })
// const p20 = p10.then(function p10Fullfilled(res){
// console.log(20)
// return res
// })
// const p30 = p20.then(function p20Fullfilled(res){
// console.log(30)
// })
new Promise((resolve) => {
console.log(1)
resolve(4)
}).then(res => {
console.log(2)
return new Promise(resolve => {
resolve('2-1')
}).then(res => res).then(res => res);
}).then(res => {
console.log(3, res)
})
// [r 40, 3]
// 1 10 2 20 30
new Promise((resolve) => {
console.log(10)
resolve(4)
}).then(res => {
console.log(20)
return res;
}).then(res => {
console.log(30)
}).then(res => {
console.log(40)
}).then(res => {
console.log(50)
}).then(res => {
console.log(60)
})