📜  尝试捕获 javascript 代码示例

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

代码示例6
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) <--

}