The Break Statement
The Break Statement
The break statement, which was briefly introduced with the switch statement, is used to exit a loop
early, breaking out of the enclosing curly braces
The break statement breaks the loop and continues executing the code after the loop (if any)
Example:
<html>
<head><title></title>
<script language="javascript">
var i=1
document.write("Implementation of break statement <br>")
while (i<10)
{
document.write(i+" ")
if(i==5)
{
break
}
i=i+1
}
</script>
</head>
<body>
</body>
</html>
Output:
Implementation of break statement
12345