语句标记要尝试的语句块,并指定一个出现异常时抛出的响应
try {nonExistentFunction();} catch (error) {console.error(error);// expected output: ReferenceError: nonExistentFunction is not defined// Note - error messages will vary depending on browser}//try {try_statements}[catch (exception_var_1 if condition_1) { // non-standard 非标准catch_statements_1}]...[catch (exception_var_2) {catch_statements_2}][finally {finally_statements}]
try_statements // 需要被执行的语句。
catch_statements_1, catch_statements_2 // 如果在try块里有异常被抛出时执行的语句。
exception_var_1, exception_var_2 // 用于保存关联catch子句的异常对象的标识符。
condition_1 // 一个条件表达式。
finally_statements //在try语句块之后执行的语句块。无论是否有异常抛出或捕获这些语句都将执行。
