JS label & break

by peterbenoit

JavaScript

function test(printTwo) {
    printing: {
        console.log("One");
        if (!printTwo) break printing;
        console.log("Two");
    }
    console.log("Three");
}

test(true);   // one, two, three
    
test(false);  // two will be skipped