-
Book Overview & Buying
-
Table Of Contents
Web Developer's Reference Guide
By :
In JavaScript, try/catch statements are use to handle exceptions present in the try code blocks.
In the try block, the statements to be evaluated are executed.
If you want to deliberately throw an exception, we would use the throw statement. This will abort the execution of the remaining statements, and the control will move to the catch block.
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.
A good practice is to use a conditional catch clause first if we anticipate that any exception will occur. An unconditional catch clause is placed last to handle...
Change the font size
Change margin width
Change background colour