The right way of using try catch javascript

The syntax for Try Catch

try {
    // Your Statement
} catch (e) {
   // Use catched error 'e'
}

Catch block gets executed Only if, the statements in try block generates an error

The syntax for Try Catch

try {
    // Your Statement
} catch (e) {
   // Use catched error 'e'
}
finally {
   // This code execute after try catch blocks
}

finally block gets executed all the times after try, catch blocks, without considering output or exceptions from above try catch blocks

Leave a Reply

(*) Required, Your email will not be published