JS break

Last Updated: March 16, 2022

break statement in JavaScript terminate the current loop

Example

const numbers = [1, 2, 3, 4, 5];
let i =0;

while(i< array.length) {
    if(i==3){
       break;
    }
    console.log(numbers[i]);
});
Test