Knowledge Walls
Ammu
Hyderabad, Andhra Pradesh, India
Passcode:
Exception in Examples of Javascript 1
955 Views

The try statement lets you test a block of code for errors.

The catch statement lets you handle the error.

The throw statement lets you create custom errors.

The finally statement lets you execute code, after try and catch, regardless of the result.

Sample
<!DOCTYPE html>
    <html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <title>heloo</title>
        
    </head>
    <body>
        <script>
            try{
              var a;
             b=parseFloat(a);
                if(isNaN(b))throw "invalid";
            }
            catch(err){
                document.writeln(err);
            }
            finally{
                document.writeln("task 2");
            }
        </script>
    </body>
</html>
Next Topics
Next lessons of current book.
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Previous Topics
Previous lessons of current book.
Examples of Javascript 1
Examples of Javascript 1
Best Lessons of "Javascript 1"
Top lessons which are viewed more times.
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details