下面代码运行结果是多少
var p = new Promise((resolve, reject) => {
reject(Error(''))
})
.then(()=>{
console.log('1')
})
.catch(()=>{
console.log('2')
})
.then(()=>{
console.log('3')
})
.catch(()=>{
console.log('4')
})
.then(()=>{
console.log('5')
})
‘A.2’,
‘B.2 3 4 5’,
‘C.2 3 5’,
‘D.2 4’
答案:C
‘当报错的时候,找到最近的catch,后续的then继续执行,但是后续的catch不执行。’
更多前端面试题,微信搜索小程序【坤坤前端笔记】,随时刷题