Add a label for the for loop statement in JavaScript

Description

The following code shows how to add a label for the for loop statement.

Example


<!--  w w  w.  j a va 2s  .c  om-->

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var count = 10;
start: for (var i=0; i < count; i++) {
document.writeln(i);
}
</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Add a label for the for loop statement in JavaScript