In JavaScript, try/catch
statements are use to handle exceptions present in the try
code blocks.
After checking and encountering an error in the statements in the try
block, the exception block is called. If the exception encountered is the same as the exception handled in the catch
block, then the control immediately shifts to the catch
block, and the statements within the catch
block are executed.
The statements presented after the erroneous statement will not be executed, unless there is a return
statement in the finally
block.