/

HTML / CSS / JavaScript Tutorial

JavaScript Statement: throw

[this page | pdf | back links]

In JavaScript, the throw statement (often used in conjunction with the try … catch statement) implements error handling. It throws an exception (technically an Error object).

 

The exception can be specified as just some text (e.g. throw "Error") or a number (e.g. throw 100) or more generally an error object, e.g. throw new Error(100,"Error").

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Reserved Words


Desktop view | Switch to Mobile