What’s the purpose of lonely code blocks in Javascript?

As I found out after googling my answer for How are labels used with statements that are not a loop?, the lonely code blocks can be related to labels:

myLabel:
{
    for(x in y) {
        break myLabel;
    }
}

Will break out not only of the loop, but of the outer code block as well.

Leave a Comment