ECMAScript: Difference between revisions

Content deleted Content added
added author
Line 69:
 
=== Imperative and structured ===
ECMAScript JavaScript<!-- How to make clearer? --> supports [[C (programming language)|C]]-style structured programming. Previously, JavaScript only supported [[Scope (computer science)|function scoping]] using the keyword <code>var</code>, but ECMAScript 2015 added the keywords <code>let</code> and <code>const</code>, allowing JavaScript to support both block scoping and function scoping. JavaScript supports [[automatic semicolon insertion]], meaning that semicolons that normally terminate a statement in C may be omitted in JavaScript.<!-- Might imply EMCAScript doesn't support automatic semicolon insertion --><ref name="Flanagan2006">{{cite book|url=https://books.google.com/books?id=2weL0iAfrEMC|title=JavaScript: The Definitive Guide|first=David|last=Flanagan|edition=5th|date=17 August 2006|publisher=O'Reilly|isbn=978-0-596-10199-2|page=16|url=https://archive.org/details/javascriptdefini0000flan|url-access=registration}}</ref>
 
Like C-style languages, [[control flow]] is done with the {{Code|code=while}}, {{Code|code=for}}, {{Code|code=do}} / {{Code|code=while}}, {{Code|code=if}} / {{Code|code=else}}, and {{Code|code=switch}} statements.<!-- missing Labels / Functions --> Functions are weakly typed and may accept and return any type. Arguments not provided default to {{Code|code=undefined}}.