控制流 / 控制流中断

let firstMatchValue = -1;
let array1 = [123];
let array2 = [234];

firstLoop: for (let i in array1) {
    for (let n in array2) {
        if (array1[i] === array2[n]) {
            firstMatchValue = array1[i];
            break firstLoop;
        }
    }
}
//firstMatchValue is 2
console.log(firstMatchValue);


A label provides a statement with an identifier that lets you refer to it elsewhere in your program. For example, you can use a label to identify a loop, and then use the break or continue statements to indicate whether a program should interrupt the loop or continue its execution.