Promise.prototype.finally()
2022年5月1日小于 1 分钟
Promise.prototype.finally()
Question
What does the code snippet to the right output by console.log
?
Snippet
Promise.resolve(1)
.finally((data) => {
console.log(data)
return Promise.reject('error')
})
.catch((error) => {
console.log(error)
throw 'error2'
})
.finally((data) => {
console.log(data)
return Promise.resolve(2).then(console.log)
})
.then(console.log)
.catch(console.log)