break

The break statement exits from the current for, for..in, for..of, switch, or while statement and transfers execution to the statement following the terminated statement.

Syntax


    break;

Example: break out of a loop

The following example is similar across for, for..in, for..of, and while statements and breaks out of a loop.

<?ev
    for(var i=0; i<5; i++){
        if(i==3){
            break;
        }
        print(i);
    }
?>

Example: break out of a switch

The following example illustrates breaking out of a switch statement from a case clause.

<?ev
    switch(val){
        case 1: 
            print('One');
            break;
        case 2:
            print('Two');
            break;
        default:
            print('Many');
    }
?>

See also continue

COVID-19 NOTICE – Business as Usual
Evance continues to provide all services and support throughout this difficult period. See our full statement here .