Labels to Control the Flow in Javascript

Let us see how to use labels to control the flow in javascript. A label can be used with break and continue statements to control the flow more precisely. A label is simply an identifier followed by a colon (:) that is applied to a statement or a block of code.
Note − Line breaks are not allowed between the ‘continue’ or ‘break’ statement and its label name. Also, there should not be any other statement in between a label name and associated loop.


The following example shows how to implement Label with a break and continue statement.

<!DOCTYPE html>

<h1>Using Labels to Control the Flow in Javascript</h1>

<p id="demo"></p>

var display = ["Welcome", "to", "easycode","one","WebApp"];
var text = "";

    text += display[i] + "<br>";    
    continue list; 
    break list;

document.getElementById("demo").innerHTML = text;

<p>Powered by</p>



Labels to Control the Flow in Javascript