The throw Statement

Navigation Aids -- This Page           Navigation Aids -- This Topic           Navigation Aids -- This Site

Review of Terms Related to This Topic

Definition and Purpose

An exception is a condition that indicates some runtime error has occurred.

An error when used in the context of our page is synonymous with the term "exception".

The term throw when used in this context means "to throw an exception". That is, to send a signal that an exception has occurred.

The term catch when used in this context means "to handle the exception". That is, to take the necessary action to recover from the run-time error.

The throw statement is used to explicitly throw an exception. In JavaScript, the throw statement is used in conjunction with the try/catch/finally statement. The explicit throw statement designed by the programmer must reside in the try clause. The catch clause performs recovery processing to prevent the user from experiencing the run-time error.

Statement Syntax

throw expression;

More on Syntax and Statement Behavior

ECMA-262 Section 12.13

The throw statement is an ECMAScript core statement and is detailed is section 12.13 of the ECMAScript Language Specification.


Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson