- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <h1>Try Catch and Finally</h1>
- <input type="button" value="Find Error" onclick="fun_err();">
- <script>
- function fun_err()
- {
- try
- {
- alert(i); // i is not defined so error occured
- }
- //if any error occur in try block catch will execute
- catch (err)
- {
- alert("Error is : " + err.message);
- }
- //finally is optional and it should execute after try and catch executed
- finally
- {
- alert("Finally Executed");
- }
- }
- </script>
- </body>
- </html>
Try catch statement:- genius student
Reviewed by Network security
on
November 04, 2019
Rating:
No comments: