Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

break in javascript

//break keyword, it breaks out of the switch block
//or from the loop.
break keyword, it breaks out of the switch block
  switch(expression) {
  case x:
    // code block
    break;
  case y:
    // code block
    break;
  default:
    // code block
}
//breaking from loop
  for(let i=0;i<=100:i++){
    console.log(i)
  if(i===40){
  console.log('Hey you hit 400!');
    break;
  }
  }
  //output i from 1 to 40 and at last Hey you hit 400!
     
 
PREVIOUS NEXT
Tagged: #break #javascript
ADD COMMENT
Topic
Name
3+4 =