1.
// 输出1和3, 2不会输出
const p = new Promise(() => {
console.log(1)
})
p.then((res) => {
console.log(2)
})
console.log(3)
2.
// 先输出3,在输出then:success1,不会输出catch
const p = new Promise((resolve, reject) => {
resolve('success1')
reject('error1')
resolve('success2')
})
p.then((res) => {
console.log('then:', res)
}).catch((err) => {
console.log('catch:', err)
})
console.log(3)