How are labels used with statements that are not a loop?

后端 未结 2 606
执笔经年
执笔经年 2021-01-02 10:41

According to the ECMAScript 5.1 spec, section 12.12, any statement can be labelled - and in a brief test my browser accepted a label before any statement. The spec also stat

2条回答
  •  孤城傲影
    2021-01-02 11:01

    Yes you can label any statement. You just need to put the statement in curly braces, i.e.

    {start:var a=1;}
    

    this will not show undefined label error.

提交回复
热议问题