var promise1 = new Promise(function(resolve, reject) {
let a ={ab:'hhhhh'};
let b;
resolve(b.a);//b.a会发生错误
});
promise1.then(
function(value) {//当promise状态为resolve时执行
console.log(value);
},
function(err){//当promise状态为rejected时执行
console.log(err+" hhjhj")
});
结果为 "TypeError: Cannot read property 'a' of undefined hhjhj"说明打印的结果是错误处理函数执行的