1https://wangdoc.com/javascript/features/error.html
1
1
let a = 1 const test = () => { a = 2; throw new Error(‘给三失败‘); // 抛出错误 a = 3; a = 4; } test(); console.log(a);
let a = 1 const testTryCatch = () => { a = 2; try { throw new Error(‘给三失败‘); // 抛出错误 a = 3; } catch (e) { console.log(e); } a = 4; } testTryCatch(); console.log(a);
原文:https://www.cnblogs.com/mailyuan/p/13045216.html