Do you know why this code compiles and what is something
?
function Box() {
something: {
alert(1);
}
}
var box = new Box();
That's a javascript label.
It is used to break or continue nested loops.
Here is the doc: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label
// Example code
myLoop:for (var i = 0; i < 10; ++i)
for (var j = 0; j < 10; ++j)
if (whatever)
break myLoop;
That is a label.
They are used in combination with break
and continue
to choose which loop the statement should apply to when you have nested loops.
It is pointless where it is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With