2009年2月19日 星期四

try & catch

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<br />{<br />//Run some code here<br />}<br />catch(err)<br />{<br />//Handle errors here<br />}


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