📜  尝试在 javascript 代码示例中捕获抛出错误

📅  最后修改于: 2022-03-11 15:03:35.503000             🧑  作者: Mango

代码示例4
try {

  alert('Start of try runs');  // (1) <--

  lalala; // error, variable is not defined!

  alert('End of try (never reached)');  // (2)

} catch(err) {

  alert(`Error has occurred!`); // (3) <--

}