try catch finally is the ECMAScript-262 third edition standard that provides exception handling mechanism. The grammar structure is as follows:
1 try{ 2 //可能会发生的错误代码 3 } 4 catch(error){ 5 //错误处理 6 }finally{ 7 //无论是否有异常都会执行 8 }
Grammar and Like most languages such as java.net, if the try{} code block catches an exception, the catch block will get an error message object (an instance of Error).
We should put the code that may cause errors in the try block, and error handling in the catch block; in js, if an error occurs in the <script></script> code block and there is no If the exception is caught, the subsequent code of the current