try..catch
In the try..catch statement,
If an error occurs in try, no error will be reported.
The statement after the error in try{ } will not be executed, but it will not affect the execution of the statement outside the try.
catch () { } will catch errors in try statements.
error.name, error.message
Error name and error message
E.g:
<script type="text/javascript"> console.log('text'); try { console.log('a'); console.log(b); //Error statement, will not be executed console.log('c') //try after the error statement will not be executed }catch (e) { console.log(e.name + " " + e.message) //If there is an error statement in the try, it will be grabbed } console.log('text') // normal output </script>
Console test:
This method will be very useful later on!