Freshers Aptitude technical questions
Freshers Job Alert
Bookmark and Share

•  Try...Catch Statement

The try...catch statement allows you to test a block of code for errors. The try block contains the code to be run, and the catch block contains the code to be executed if an error occurs.

Syntax

try { //Run some code here } catch(err) { //Handle errors here }

Note that try...catch is written in lowercase letters. Using uppercase letters will generate a JavaScript error!