The break statement has a very simple syntax:
break;
This statement is valid only within the body of a while, for, or for/in loop. Using it outside of a loop is a syntax error. When executed, the break statement exits the currently running loop. This statement is usually used to exit a loop prematurely when, for whatever reason (perhaps when an error condition arises), there is no longer any need to complete the loop. The following example searches the elements of an array for a particular value. If the value is found, a break statement terminates the loop:
for(i =index.html 0; i < a.length; i++) { if (a[i] == target) break; }
file: /Techref/language/java/script/definitive/ch05_07.htm, 3KB, , updated: 2019/10/14 15:00, local time: 2024/12/27 14:51,
13.58.221.124:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://linistepper.com/techref/language/java/script/definitive/ch05_07.htm"> [Chapter 5] 5.7 break</A> |
Did you find what you needed? |