Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does mean for loop with one semicolon?

Can please someone give an example of third for loop from specification and explain what does it mean?

14.7.4 The for Statement

  • Syntax

    MEDevel.com: Open-source for Healthcare and Education

    Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

    Visit Medevel

    • ForStatement[Yield, Await, Return] :

      • for ( [lookahead ≠ let [] Expression[~In, ?Yield, ?Await] opt ; Expression[+In, ?Yield, ?Await] opt ; Expression[+In, ?Yield, ?Await] opt ) Statement[?Yield, ?Await, ?Return]

      • for ( var VariableDeclarationList[~In, ?Yield, ?Await] ; Expression[+In, ?Yield, ?Await] opt ; Expression[+In, ?Yield, ?Await] opt ) Statement[?Yield, ?Await, ?Return]

      • for ( LexicalDeclaration[~In, ?Yield, ?Await] Expression[+In, ?Yield, ?Await] opt ; Expression[+In, ?Yield, ?Await] opt ) Statement[?Yield, ?Await, ?Return]

>Solution :

If you look at the definition of LexicalDeclaration, you can see it is defined as:

  • LexicalDeclaration[In, Yield, Await] :
    • LetOrConst BindingList[?In, ?Yield, ?Await] ;

So all three cases of for loops have two semicolons. Lexical declarations are not expressions and so they have chosen to include the semicolon in its definition, rather than following every use of LexicalDeclaration with ;.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading