Promotic

break - statement of language JavaScript

Description:
Exits a switch statement and a loop statement (for, while, do...while).
Syntax:

break
Note:
For switch statement:
It is located inside the statement. The break statement jumps out of the switch statement (the code execution moves behind the switch statement).
For loop statement (for, while, do...while):
It is located inside the cycle. The break statement terminates the cycle (the code execution is moved to behind the cycle).


For similar purpose in the VBScript language is used the statement Exit.
See also:
Exit switch statement:
JavaScriptSelect and copy to clipboard

var nNum = 17;
switch (nNum)
{
case 15:
Pm.Debug("case=15");
break;
case 17:
Pm.Debug("case=17");
break;
default:
Pm.Debug("switch default=" + nNum);
break;
}
Exit for statement:
JavaScriptSelect and copy to clipboard

var iRow;
for (iRow = 0; iRow <= 5; iRow++)
{
if (iRow == 3)
{
break;
}
Pm.Debug("iRow = " + iRow);
}
Exit while statement:
JavaScriptSelect and copy to clipboard

var iRow = 0;
while (iRow <= 5)
{
if (iRow == 3)
{
break;
}
Pm.Debug("iRow = " + iRow);
iRow++;
}
Exit do...while statement:
JavaScriptSelect and copy to clipboard

var iRow = 0;
do
{
if (iRow == 3)
{
break;
}
Pm.Debug("iRow = " + iRow);
iRow++;
} while (iRow <= 5);
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.