Home > Web Front-end > JS Tutorial > js exception handling try catch finally explanation

js exception handling try catch finally explanation

一个新手
Release: 2017-10-26 09:42:48
Original
1920 people have browsed it

Grammar structure

try catch finally is the ECMAScript-262 third edition standard that provides exception handling mechanism. The grammar structure is as follows:


try{
//可能会发生的错误代码
}
catch(error){
//错误处理
}finally{
 //无论是否有异常都会执行
}
Copy after login

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

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template