Exception Handling with try() and catch()

The source code for this example defines two blocks: a try block and a catch block. Exceptions that occur during the processing the JavaScript statements in the try block "throw" an exception automatically; the catch block catches and processes those exceptions.

In this case, a JavaScript statement has passed the number 13 to a function to determine the name associated with the 13th month. There is no 13th month in the Julian calendar, of course, so the out-of-array-bounds exception generated is thrown by the function and caught (and processed) by the catch block.