Monday 27 August 2018

JavaScript: break in label form

label is a group of statements, identified by using labelname.

Syntax
    labelName:{
      statement 1
      statement 2
      …....
      statement N
    }
   
break is also available in label form.

Syntax
break labelName;

breakLabel.html
<!DOCTYPE html>

<html>

<head>
    <title>break label example</title>
</head>

<body>
    <script type="text/javascript">
        outer:
            for (var i = 0; i < 10; i++) {
                inner: for (var j = 0; j < 10; j++) {
                    document.write(i + "," + j + "<br />");

                    if (i * j > 10)
                        break outer;
                }
            }
    </script>
</body>

</html>



Previous                                                 Next                                                 Home

No comments:

Post a Comment