JavaScript throw Keyword
In this tutorial, you will learn about JavaScript throw keyword with the help of Examples:
So far, you have only been catching exceptions that are thrown by the JavaScript run-time errors. However, it is possible for your program to throw an exception explicitly, using the throw statement. The general form of throw is shown here -
Example 1 –
Output -
Example 2 -
Output -