Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
ECMAScript
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Features == {{expand section|date=February 2017}} {{main|ECMAScript syntax|JavaScript#Features}} The ECMAScript language includes [[structured programming|structured]], [[dynamic programming language|dynamic]], [[functional programming|functional]], and [[prototype-based programming|prototype-based]] features.<ref>{{cite web |url=http://www.ecmascript.org/about.php |title=About |publisher=ECMAScript |access-date=2009-12-17 |url-status=dead |archive-url=https://archive.today/20120802115457/http://www.ecmascript.org/about.php |archive-date=2012-08-02 }}</ref> === 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|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}}. === Weakly typed === ECMAScript is [[weakly typed]]. This means that certain types are assigned implicitly based on the operation being performed. However, there are several quirks in JavaScript's implementation of the conversion of a variable from one type to another. These quirks have been the subject of a <!-- humorous --> talk entitled ''Wat''.<ref>{{cite conference |last1=Bernhardt |first1=Gary |title=Wat |url=https://www.destroyallsoftware.com/talks/wat |website=Destroy All Software |conference=CodeMash 2012 |access-date=2021-08-18 |archive-date=2019-10-28 |archive-url=https://web.archive.org/web/20191028204723/https://www.destroyallsoftware.com/talks/wat |url-status=live }}</ref><ref>{{cite magazine |last1=Gilbertson |first1=Scott |title=Jokes for Nerds: Wat Moments in Programming |url=https://www.wired.com/2012/01/jokes-for-nerds-wat-moments-in-programming/ |access-date=22 August 2021 |magazine=Wired |date=26 January 2012 |archive-date=23 August 2020 |archive-url=https://web.archive.org/web/20200823123837/https://www.wired.com/2012/01/jokes-for-nerds-wat-moments-in-programming/ |url-status=live }}</ref> === Dynamic === ECMAScript is dynamically typed. Thus, a type is associated with a value rather than an expression. ECMAScript supports various ways to test the type of objects, including [[duck typing]].<ref>{{cite web|url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures|title=JavaScript data types and data structures β JavaScript {{pipe}} MDN|date=2017-02-16|website=Developer.mozilla.org|access-date=2017-02-24|archive-date=2017-03-14|archive-url=https://web.archive.org/web/20170314230542/https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures|url-status=live}}</ref> === Transpiling === {{Main|JavaScript#transpilers}} Since ES 2015, transpiling JavaScript has become very common. Transpilation is a [[source-to-source compilation]] in which newer versions of JavaScript are used, and a transpiler rewrites the source code so that it is supported by older browsers. Usually, transpilers transpile down to ES3 to maintain compatibility with all versions of browsers. The settings to transpile to a specific version can be configured according to need. Transpiling adds an extra step to the build process and is sometimes done to avoid needing [[Polyfill (programming)|polyfills]]. Polyfills create new features for older environments that lack them.<!-- The polyfill article is much better --> Polyfills do this at runtime in the interpreter, such as the user's browser or on the server. Instead, transpiling rewrites the ECMA code itself during the build phase of development before it reaches the interpreter.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)