Break statement
Typically used in loops, traversal statements. When a break statement is used in a looping statement, the program terminates the loop and executes the statement following the loop, usually jumping out of a statement that is always associated with a statement if the condition is met. You can say: jump out of the statement is the bane of the loop process, as long as the execution of the jump statement, The loop process terminates immediately.
(keyword, break)
Attention:
1, can only be executed in the while and for statements, execution out of the statement break the entire loop
2. Executing a break statement can only interrupt the loop body of the layer closest to the jump statement
Example:
1. Single-loop use of jump-out statements
var i=0 while (true) //Set Loop if (i==27) break //Judge meet condition to jump out while
When the condition of the statement "if(i==27)" is established, a jump statement is executed, which interrupts the while statement to continue execution, thus ending the while statement.
2. Use the jump statement in case of nested loops.
while (true) for (var i=0;i<100;i++) if (i = =) break//only jumps out of the For loop body End
A jump statement is executed when the condition of the statement "if (i = = 50)" is true. According to note 2 We know that the jump statement only interrupts the for statement to continue execution, but does not affect the execution of the loop statement.
Seventh lesson fourth, T language Process statement (version 5.0)