Catch method name not found exception in JavaScript

Description

The following code shows how to catch method name not found exception.

Example


<html>
<head>
<script type="text/javascript">
try {<!--from   w  ww. j av  a2 s  . co  m-->
window.nonExistentFunction();
document.writeln("Method completed.");
} catch (exception) {
document.writeln("An exception occurred.");
} finally {
document.writeln("End of try?catch test.");
}
</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Catch method name not found exception in JavaScript
Home »
  Javascript Tutorial »
    Statement »
      Exception
Javascript Tutorial Exception
Catch SyntaxError Exception in JavaScript
Catch an error in JavaScript
Catch and row exceptions in JavaScript
Catch method name not found exception in Ja...
Check the exception name and output excepti...
Create an Error with error code and message...
Get Exception message in JavaScript
Get Exception name in JavaScript
Throw exception out of a function in JavaSc...
Try catch user exception in JavaScript