Use throw statement as return - Javascript Statement

Javascript examples for Statement:throw

Description

Use throw statement as return

Demo Code

ResultView the demo in separate window

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
   <head> 
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
   </head> 
   <body> 
      <script type="text/javascript">
function test1(){/*  ww w.j av  a 2 s .c  o  m*/
    test2();
    test3();
}
function test2(){
    console.log(2);
    throw '';
    test4();
    test5();
}
function test3(){
    console.log(3);
}
function test4(){
    console.log(4);
}
function test5(){
    console.log(5);
}
test1();

      </script>  
   </body>
</html>

Related Tutorials