Javascript examples for Statement:break
Using the break statement with a label reference, to "jump out" of a code block:
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var cars = ["a","b","c","d","e"]; var text = ""; list: {//w ww . j av a2 s . c o m text += cars[0] + "<br>"; text += cars[1] + "<br>"; text += cars[2] + "<br>"; break list; text += cars[3] + "<br>"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>