这段JS的代码的运行结果是?
(() => {let x, y;
try{
throw new Error();
}catch(x){
(x=1),(y=2);
console.log(x);
}
console.log(x);
console.log(y);
})() 1
undefined
2
(() => {
let x, y;
try {
throw new Error();
} catch (z) { // 该处的x是个局部变量,为便于理解,我们可以改为z,所以z只在catch块有效。
(x = 1), (z = 3), (y = 2);
console.log(z);
}
console.log(x);
console.log(y);
})()
页:
[1]