try catch mdn code example
Example 1: try catch javascript
"The try...catch statement marks a block of statements to try and specifies"
"a response should an exception be thrown."
try {
nonExistentFunction();
} catch (error) {
console.error(error);
}
Example 2: finally always after try catch
Finally block is ALWAYS executed AFTER try / catch Javascript blocks.
Example 3: try catch throwing error in javascript
let json = '{ "age": 30 }';
try {
let user = JSON.parse(json);
alert( user.name );
} catch (e) {
alert( "doesn't execute" );
}