Jumps the flow of control to the end of the immediate loop and executes the first instruction following the loop. Break is different from a return, which leaves all loops and the function scope. Break is only meaningful inside a loop.
function Foo()
{
while (true)
{
while (z < 5)
{
...
if (x == false)
{
break; // jumps to line following while (z < 5) {}
}
if (y == true)
{
return 5; // returns from Foo() immediately
}
}
if (x == false)
{
break; // jumps to line following while (true) {}
}
}
...
return -1; // returns from Foo() immediately
}
|
Copyright © 2014 CA Technologies.
All rights reserved.
|
|