Promise.all()
2022年5月1日小于 1 分钟
Promise.all()
Question
What does the code snippet to the right output by console.log
?
Snippet
(async () => {
await Promise.all([]).then((value) => {
console.log(value)
}, (error) => {
console.log(error)
})
await Promise.all([1,2,Promise.resolve(3), Promise.resolve(4)]).then((value) => {
console.log(value)
}, (error) => {
console.log(error)
})
await Promise.all([1,2,Promise.resolve(3), Promise.reject('error')]).then((value) => {
console.log(value)
}, (error) => {
console.log(error)
})
})()