Using the label Statement : For : Language Basics : JavaScript DHTML examples (example source code) Organized by topic

JavaScript DHTML
C++
PHP


JavaScript DHTML  »  Language Basics   » [  For  ]   
 



Using the label Statement

Please note that some example is only working under IE or Firefox.


/*
JavaScript Unleashed, Third Edition
by Richard Wagner and R. Allen Wyke 

ISBN: 067231763X
Publisher Sams CopyRight 2000

*/


<html>
<head>
  <title>JavaScript Unleashed</title>
</head>
<body>
  <script language="JavaScript1.2" type="text/javascript">  <!--
    // Declare variables
    var stopX = 3;
    var stopY = 8;
   
    document.write("All x,y pairs between (0,0) and (");
    document.write(stopX + "," + stopY + "):<br>");
   
  loopX:
    for(var x = 0; x < 10; ++x){
      for(var y = 0; y < 10; ++y){
        document.write("("+x + "," + y +") ");
        if((x == stopX&& (y == stopY)){
          break loopX;
        }
      }
      document.write("<br>");
    }
    document.write("<br>After completing the loop, x equals : " + x);
    document.writeln("<br>After completing the loop, y equals : " + y);
  // -->
  </script>
</body>
</html>

           
       
Related examples in the same category
1.  For loop for lines
2.   Drawing a Christmas Tree Using Nested For Loops
3.  For loop
4.  Using a for..in Loop in JavaScript
5.  A Demonstration of a Nested Loop
6.  A for Loop Used to Count from 0 to 99
7.  Using the continue and break Statements
8.  Use of the for Statement
9.  The break Statement
10.  The continue Statement
11.  Labeled Statements
12.  Plain for loop
13.  For loop with alert dialog
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.