icubesire

revenuehits

Search in Desigs Guru

Friday, October 26, 2012

The Throw Statement

http://designsguru.blogspot.in

The throw statement allows you to create an exception. If you use this statement together with the try...catch statement, you can control program flow and generate accurate error messages.

Syntax

throw exception
The exception can be a string, integer, Boolean or an object.
Note that throw is written in lowercase letters. Using uppercase letters will generate a JavaScript error!

Example

The example below determines the value of a variable called x. If the value of x is higher than 10, lower than 5, or not a number, we are going to throw an error. The error is then caught by the catch argument and the proper error message is displayed:

Example




No comments:

Post a Comment

Thanks

LinkWithin

Related Posts Plugin for WordPress, Blogger...