what the difference between break with label and without label in javascript
- by dramasea
<script type="text/javascript">
var num = 0;
for(var i = 0; i < 10; i++){
for(var j = 0; j < 10 ; j++){
if(i == 5 && j == 5){
break;
}
num++;
}
}
alert(num);
</script>
In the above code,i expect the result to be 55 but why the result is 95.
But why if i added that the label, the result become 55?Can someone tell me thanks!!
<script type="text/javascript">
var num = 0;
outermost:
for(var i = 0; i < 10; i++){
for(var j = 0; j < 10 ; j++){
if(i == 5 && j == 5){
break outermost;
}
num++;
}
}
alert(num);
</script>