ECMAScript
Paradigm | Multi-paradigm: prototype-based, functional, imperative |
---|---|
Designed by | Brendan Eich, Ecma International |
First appeared | 1997 |
Typing discipline | weak, dynamic |
Website | www |
Major implementations | |
JavaScript, SpiderMonkey, V8, ActionScript, JScript, QtScript, InScript, Google Apps Script | |
Influenced by | |
Self, HyperTalk, AWK, C, CoffeeScript, Perl, Python, Java, Scheme |
![]() | |
Filename extensions |
.es |
---|---|
Internet media type |
application/ecmascript |
Developed by | Sun Microsystems, Ecma International |
Initial release | June 1997 |
Latest release | Edition 12 (June 2021 ) |
Type of format | Scripting language |
Website | ECMA-262, ECMA-290, ECMA-327, ECMA-357, ECMA-402 |
ECMAScript (/ˈɛkməskrɪpt/) (or ES)[1] is a general-purpose programming language, standardised by Ecma International according to the document ECMA-262. It is a JavaScript standard meant to ensure the interoperability of web pages across different web browsers.[2] ECMAScript is commonly used for client-side scripting on the World Wide Web, and it is increasingly being used for writing server applications and services using Node.js.
ECMAScript, ECMA-262 and JavaScript[edit]
ECMA-262 or the ECMAScript Language Specification defines the ECMAScript Language, or just ECMAScript (aka JavaScript).[3] ECMA-262 only specifies language syntax and semantics of the core API, such as Array, Function, and globalThis, while valid implementations of JavaScript add their own functionality like input/output or filesystem handling.
History[edit]
The ECMAScript specification is a standardised specification of a scripting language developed by Brendan Eich of Netscape; initially named Mocha, then LiveScript, and finally JavaScript.[4] In December 1995, Sun Microsystems and Netscape announced JavaScript in a press release.[5] In November 1996, Netscape announced a meeting of the Ecma International standards organization to advance the standardisation of JavaScript.[6] The first edition of ECMA-262 was adopted by the Ecma General Assembly in June 1997. Several editions of the language standard have been published since then. The name "ECMAScript" was a compromise between the organizations involved in standardising the language, especially Netscape and Microsoft, whose disputes dominated the early standards sessions. Eich commented that "ECMAScript was always an unwanted trade name that sounds like a skin disease."[7] ECMAScript has been formalised through operational semantics by work at Stanford University and the Department of Computing, Imperial College London for security analysis and standardisation.[8]
Versions[edit]
There are eleven editions of ECMA-262 published. Work on version 12 of the standard was finalised in June 2021.[9]
Edition | Date published | Name | Changes from prior edition | Editor |
---|---|---|---|---|
1 | June 1997 | First edition | Guy L. Steele Jr. | |
2 | June 1998 | Editorial changes to keep the specification fully aligned with ISO/IEC 16262 international standard | Mike Cowlishaw | |
3 | December 1999 | Added regular expressions, better string handling, new control statements, try/catch exception handling, tighter definition of errors, formatting for numeric output, and other enhancements | Mike Cowlishaw | |
4 | Abandoned (last draft 30 June 2003) | Fourth Edition was abandoned, due to political differences concerning language complexity. Many features proposed for the Fourth Edition have been completely dropped; some were incorporated into the sixth edition. | ||
5 | December 2009 | Adds "strict mode," a subset intended to provide more thorough error checking and avoid error-prone constructs. Clarifies many ambiguities in the 3rd edition specification, and accommodates behaviour of real-world implementations that differed consistently from that specification. Adds some new features, such as getters and setters, library support for JSON, and more complete reflection on object properties.[10] | Pratap Lakshman, Allen Wirfs-Brock | |
5.1 | June 2011 | This edition 5.1 of the ECMAScript standard is fully aligned with the third edition of the international standard ISO/IEC 16262:2011. | Pratap Lakshman, Allen Wirfs-Brock | |
6 | June 2015[11] | ECMAScript 2015 (ES2015) | See 6th Edition – ECMAScript 2015 | Allen Wirfs-Brock |
7 | June 2016[12] | ECMAScript 2016 (ES2016) | See 7th Edition – ECMAScript 2016 | Brian Terlson |
8 | June 2017[13] | ECMAScript 2017 (ES2017) | See 8th Edition – ECMAScript 2017 | Brian Terlson |
9 | June 2018[14] | ECMAScript 2018 (ES2018) | See 9th Edition – ECMAScript 2018 | Brian Terlson |
10 | June 2019[15] | ECMAScript 2019 (ES2019) | See 10th Edition – ECMAScript 2019 | Brian Terlson, Bradley Farias, Jordan Harband |
11 | June 2020[16] | ECMAScript 2020 (ES2020) | See 11th Edition – ECMAScript 2020 | Jordan Harband, Kevin Smith |
12 | June 2021[9] | ECMAScript 2021 (ES2021) | See 12th Edition – ECMAScript 2021 | Jordan Harband, Shu-yu Guo, Michael Ficarra, Kevin Gibbons |
In June 2004, Ecma International published ECMA-357 standard, defining an extension to ECMAScript, known as ECMAScript for XML (E4X). Ecma also defined a "Compact Profile" for ECMAScript – known as ES-CP, or ECMA 327 – that was designed for resource-constrained devices, which was withdrawn in 2015.[17]
4th Edition (abandoned)[edit]
The proposed fourth edition of ECMA-262 (ECMAScript 4 or ES4) would have been the first major update to ECMAScript since the third edition was published in 1999. The specification (along with a reference implementation) was originally targeted for completion by October 2008.[18] The first draft was dated February 1999.[19] An overview of the language was released by the working group on 23 October 2007.[20]
By August 2008, the ECMAScript 4th edition proposal had been scaled back into a project code named ECMAScript Harmony. Features under discussion for Harmony at the time included:
- classes,
- a module system,
- optional type annotations and static typing, probably using a structural type system,
- generators and iterators,
- destructuring assignment, and
- algebraic data types.
The intent of these features was partly to better support programming in the large, and to allow sacrificing some of the script's ability to be dynamic to improve performance. For example, Tamarin – the virtual machine for ActionScript, developed and open-sourced by Adobe – has just-in-time compilation (JIT) support for certain classes of scripts.
In addition to introducing new features, some ES3 bugs were proposed to be fixed in edition 4.[21][22] These fixes and others, and support for JSON encoding/decoding, have been folded into the ECMAScript, 5th Edition specification.[23]
Work started on Edition 4 after the ES-CP (Compact Profile) specification was completed, and continued for approximately 18 months where slow progress was made balancing the theory of Netscape's JavaScript 2 specification with the implementation experience of Microsoft's JScript .NET. After some time, the focus shifted to the ECMAScript for XML (E4X) standard. The update has not been without controversy. In late 2007, a debate between Eich, later the Mozilla Foundation's CTO, and Chris Wilson, Microsoft's platform architect for Internet Explorer, became public on a number of blogs. Wilson cautioned that because the proposed changes to ECMAScript made it backwards incompatible in some respects to earlier versions of the language, the update amounted to "breaking the Web,"[24] and that stakeholders who opposed the changes were being "hidden from view".[25] Eich responded by stating that Wilson seemed to be "repeating falsehoods in blogs" and denied that there was attempt to suppress dissent and challenged critics to give specific examples of incompatibility.[26] He pointed out that Microsoft Silverlight and Adobe AIR rely on C# and ActionScript 3 respectively, both of which are larger and more complex than ECMAScript Edition 3.[27]
5th Edition[edit]
Yahoo, Microsoft, Google, and other 4th edition dissenters formed their own subcommittee to design a less ambitious update of ECMAScript 3, tentatively named ECMAScript 3.1. This edition would focus on security and library updates, with a large emphasis on compatibility. After the aforementioned public sparring, the ECMAScript 3.1 and ECMAScript 4 teams agreed on a compromise: the two editions would be worked on, in parallel, with coordination between the teams to ensure that ECMAScript 3.1 remains a strict subset of ECMAScript 4 in both semantics and syntax.
However, the differing philosophies in each team resulted in repeated breakages of the subset rule, and it remained doubtful that the ECMAScript 4 dissenters would ever support or implement ECMAScript 4 in the future. After over a year since the disagreement over the future of ECMAScript within the Ecma Technical Committee 39, the two teams reached a new compromise in July 2008: Brendan Eich announced that Ecma TC39 would focus work on the ECMAScript 3.1 (later renamed to ECMAScript, 5th Edition) project with full collaboration of all parties, and vendors would target at least two interoperable implementations by early 2009.[28][29] In April 2009, Ecma TC39 published the "final" draft of the 5th edition and announced that testing of interoperable implementations was expected to be completed by mid-July.[30] On December 3, 2009, ECMA-262 5th edition was published.[31]
6th Edition – ECMAScript 2015[edit]
The 6th edition, ECMAScript 6 (ES6) and later renamed to ECMAScript 2015, was finalised in June 2015.[11][32] This update adds significant new syntax for writing complex applications, including class declarations (class Foo { ... }
), ES6 modules like import * as moduleName from "..."; export const Foo
, but defines them semantically in the same terms as ECMAScript 5 strict mode. Other new features include iterators and for...of
loops, Python-style generators, arrow function expression (() => {...}
), let
keyword for local declarations, const
keyword for constant local declarations, binary data, typed arrays, new collections (maps, sets and WeakMap), promises, number and math enhancements, reflection, proxies (metaprogramming for virtual objects and wrappers) and template literals for strings.[33][34] The complete list is extensive.[35][36] As the first "ECMAScript Harmony" specification, it is also known as "ES6 Harmony."
7th Edition – ECMAScript 2016[edit]
The 7th edition, or ECMAScript 2016, was finalised in June 2016.[12] Its features include block-scoping of variables and functions, destructuring patterns (of variables), proper tail calls, exponentiation operator **
for numbers, await
, async
keywords for asynchronous programming (as a preparation for ES2017), and the Array.prototype.includes
function.[12][37]
The exponentiation operator is equivalent to Math.pow
, but provides a simpler syntax similar to languages like Python, F#, Perl, and Ruby.async
/await
was hailed as an easier way to use promises and develop asynchronous code.
8th Edition – ECMAScript 2017[edit]
The 8th edition, or ECMAScript 2017, was finalised in June 2017.[13] Its features include the Object.values
, Object.entries
and Object.getOwnPropertyDescriptors
functions for easy manipulation of Objects, async/await
constructions which use generators and promises, and additional features for concurrency and atomics.[38][13]
9th Edition – ECMAScript 2018[edit]
The 9th edition, or ECMAScript 2018, was finalised in June 2018.[14] New features include the spread operator, rest parameters, asynchronous iteration, Promise.prototype.finally
and additions to RegExp.[14]
The spread operator allows for the easy copying of object properties, as shown below.
let object = {a: 1, b: 2}
let objectClone = Object.assign({}, object) // before ES9
let objectClone = {...object} // ES9 syntax
let otherObject = {c: 3, ...object}
console.log(otherObject) // -> {c: 3, a: 1, b: 2}
10th Edition – ECMAScript 2019[edit]
The 10th edition, or ECMAScript 2019, was published in June 2019.[15] Added features include, but are not limited to, Array.prototype.flat
, Array.prototype.flatMap
, changes to Array.sort
and Object.fromEntries
.[15]
Array.sort
is now guaranteed to be stable, meaning that elements with the same sorting precedence will appear in the same order in the sorted array. Array.prototype.flat(depth=1)
flattens an array to a specified depth, meaning that all subarray elements (up to the specified depth) are concatenated recursively.
11th Edition – ECMAScript 2020[edit]
The 11th edition, or ECMAScript 2020, was published in June 2020.[16] In addition to new functions, this version introduces a BigInt
primitive type for arbitrary-sized integers, the nullish coalescing operator, and the globalThis object.[16]
BigInts are created either with the BigInt
constructor or with the syntax 10n
, where "n" is placed after the number literal. BigInts allow the representation and manipulation of integers beyond Number.MAX_SAFE_INTEGER
, while Numbers are represented by a double-precision 64-bit IEEE 754 value. The built-in functions in Math
are not compatible with BigInts; for example, exponentiation of BigInts must be done with the **
operator instead of Math.pow
.
The nullish coalescing operator, ??
, returns its right-hand side operand when its left-hand side is null
or undefined
. This contrasts with the ||
operator, which would return "string"
for all "falsy" values, such as the ones below.
undefined ?? "string" // -> "string"
null ?? "string" // -> "string"
false ?? "string" // -> false
NaN ?? "string" // -> NaN
Optional chaining makes it possible to access the nested properties of an object without having an AND check at each level.
An example is const zipcode = person?.address?.zipcode
. If any of the properties are not present, zipcode
will be undefined
.
12th Edition – ECMAScript 2021[edit]
![]() | This section needs expansion. You can help by adding to it. (June 2021) |
The 12th edition, or ECMAScript 2021, was published in June 2021.[9]
ES.Next[edit]
ES.Next is a dynamic name that refers to whatever the next version is at the time of writing. ES.Next features include finished proposals (aka "stage 4 proposals") as listed at finished proposals that are not part of a ratified specification. The language committee follows a "living spec" model, so these changes are part of the standard, and ratification is a formality.[citation needed]
Features[edit]
![]() | This section needs expansion. You can help by adding to it. (February 2017) |
The ECMAScript language includes structured, dynamic, functional, and prototype-based features.[39]
Imperative and structured[edit]
ECMAScript JavaScript supports C style structured programming. Previously, JavaScript only supported function scoping using the keyword var
, but ECMAScript 2015 added the keywords let
and const
allowing JavaScript to support both block scoping and function scoping. JavaScript supports automatic semicolon insertion, meaning that semicolons that are normally used to terminate a statement in C may be omitted in JavaScript.[40]
Like C-style languages, control flow is done with the while
, for
, do/while
, if/else
, and switch
statements. Functions are weakly typed and may accept and return any type. Arguments not provided default to undefined
.
Weakly typed[edit]
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 drawn criticism from many developers.[citation needed]
Dynamic[edit]
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.[41]
Transpiling[edit]
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 transpiling 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 polyfills. Polyfills create new features for older environments that lack them. 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.
Conformance[edit]
In 2010, Ecma International started developing a standards test for Ecma 262 ECMAScript.[42] Test262 is an ECMAScript conformance test suite that can be used to check how closely a JavaScript implementation follows the ECMAScript Specification. The test suite contains thousands of individual tests, each of which tests some specific requirement(s) of the ECMAScript specification. The development of Test262 is a project of the Ecma Technical Committee 39 (TC39). The testing framework and individual tests are created by member organizations of TC39 and contributed to Ecma for use in Test262.
Important contributions were made by Google (Sputnik testsuite) and Microsoft who both contributed thousands of tests. The Test262 testsuite consisted of 38014 tests as of January 2020[update].[43] ECMAScript specifications through ES7 are well-supported in major web browsers. The table below shows the conformance rate for current versions of software with respect to the most recent editions of ECMAScript.
Scripting engine | Reference application(s) | Conformance[44] | |||
---|---|---|---|---|---|
ES5[45] | ES6 (2015)[46] | ES7 (2016)[47] | Newer (2017+)[47][48] | ||
Chakra | Microsoft Edge 18 | 100% | 96% | 100% | 33% |
SpiderMonkey | Firefox 79 | 100% | 98% | 100% | 100% |
V8 | Google Chrome 84, Microsoft Edge 84, Opera 70 | 100% | 98% | 100% | 100% |
JavaScriptCore | Safari 13.1 | 99% | 99% | 100% | 84% |
See also[edit]
- Comparison of JavaScript engines
- ECMAScript for XML (E4X)
- JavaScript
- JScript
- List of ECMAScript engines
References[edit]
- ^
Stefanov, Stoyan (2010). JavaScript Patterns. O'Reilly Media, Inc. p. 5. ISBN 9781449396947. Retrieved 2016-01-12.
The core JavaScript programming language [...] is based on the ECMAScript standard, or ES for short.
- ^ Wirfs-Brock, Allen; Eich, Brendan (2020). "JavaScript: The First 20 Years". Proceedings of the ACM on Programming Languages. 4: 1–189. doi:10.1145/3386327. S2CID 219603695.
- ^ https://tc39.es/ecma262/
- ^ Krill, Paul (2008-06-23). "JavaScript creator ponders past, future". InfoWorld. Retrieved 2013-10-31.
- ^ "Netscape and Sun announce JavaScript, the Open, Cross-platform Object Scripting Language for Enterprise Networks and the Internet". Netscape. 1995-12-04. Archived from the original on 2002-06-06. Retrieved 2019-11-04.
- ^ "Industry Leaders to Advance Standardization of Netscape's JavaScript at Standards Body Meeting". Netscape. November 15, 1996. Archived from the original on 1998-12-03. Retrieved 2013-10-31.
- ^ "Will there be a suggested file suffix for es4?". Mail.mozilla.org. 2006-10-03. Retrieved 2021-05-05.
- ^ Maffeis, Sergio; Mitchell, John C.; Taly, Ankur. "An Operational Semantics for JavaScript" (PDF). Association for Computing Machinery.
- ^ a b c "ECMAScript 2021 Language Specification". Ecma International. June 2021.
- ^ "Changes to JavaScript, Part 1: EcmaScript 5". YouTube. 2009-05-18. Retrieved 2013-10-31.
- ^ a b "ECMAScript 2015 Language Specification". Ecma International. June 2015.
- ^ a b c "ECMAScript 2016 Language Specification". Ecma International. June 2016.
- ^ a b c "ECMAScript 2017 Language Specification". Ecma International. June 2017.
- ^ a b c "ECMAScript 2018 Language Specification". Ecma International. June 2018.
- ^ a b c "ECMAScript 2019 Language Specification". Ecma International. June 2019.
- ^ a b c "ECMAScript 2020 Language Specification". Ecma International. June 2020.
- ^ 2015-03-24 Meeting Notes. ESDiscuss. Also see Ecma withdrawn Standards. ECMA.
- ^ "ES4 overview paper released". Mail.mozilla.org. Retrieved 2013-10-31.
- ^ "The Real Story Behind ECMAScript 4".
- ^ "Proposed ECMAScript 4th Edition – Language Overview" (PDF). ecmascript.org. 23 October 2007. Archived from the original (PDF) on 13 July 2010.
- ^ John Resig. "John Resig – Bug Fixes in JavaScript 2". Ejohn.org. Retrieved 2013-10-31.
- ^ "Compatibility Between ES3 and Proposed ES4" (PDF). Ecmascript.org. Archived from the original (PDF) on 2014-07-24. Retrieved 2013-10-31.
- ^ "ECMAScript Language Specification" (PDF). Ecma International. 2009-04-19. Archived from the original (PDF) on 2009-04-19. Retrieved 2018-03-19.
- ^ "ECMAScript 3 and Beyond – IEBlog – Site Home – MSDN Blogs". Blogs.msdn.com. 2007-10-30. Retrieved 2013-10-31.
- ^ "What I think about ES4. – Albatross! – Site Home – MSDN Blogs". Blogs.msdn.com. 2007-10-31. Retrieved 2013-10-31.
- ^ "Open letter to Chris Wilson". Brendan Eich. 2007-10-31. Retrieved 2013-10-31.
- ^ "JavaScript 2 and the Open Web". 2007-11-20. Retrieved 2014-01-20.
- ^ "ECMAScript Harmony". Mail.mozilla.org. Retrieved 2013-10-31.
- ^ "A Major Milestone in JavaScript Standardization – JScript Blog – Site Home – MSDN Blogs". Blogs.msdn.com. 2009-04-09. Retrieved 2013-10-31.
- ^ "Ecma International finalises major revision of ECMAScript". Ecma International. 2009-04-09. Retrieved 2009-05-22.
- ^ "Ecma previous news". Ecma-international.org. Retrieved 2020-03-29.
- ^ Krill, Paul. "It's official: ECMAScript 6 is approved". InfoWorld. Retrieved 2018-03-19.
- ^ "5 Great Features in EcmaScript 6 (ES6 Harmony) – Wintellect". Wintellect. 2014-03-24. Archived from the original on 2017-07-22. Retrieved 2018-03-19.
- ^ "ECMAScript 6 (ES6): What's New In The Next Version Of JavaScript". Smashing Magazine. 2015-10-28. Retrieved 2018-03-19.
- ^ "ECMAScript 6: New Features: Overview and Comparison". es6-features.org. Retrieved 2018-03-19.
- ^ "Standard ECMA-262 6th Edition / June 2015 ECMAScript 2015 Language Specification 14.2 Arrow Function Definitions". www.ecma-international.org. 2015.
- ^ Saboff, Michael (2016-05-23). "ECMAScript 6 Proper Tail Calls in WebKit". WebKit. Retrieved 2019-04-11.
- ^ "ECMAScript 2017 (ES8): the final feature set". 2ality. Retrieved 2018-04-23.
- ^ "About". ECMAScript. Archived from the original on 2012-08-02. Retrieved 2009-12-17.
- ^ David Flanagan (17 August 2006). JavaScript: The Definitive Guide: The Definitive Guide. "O'Reilly Media, Inc.". p. 16. ISBN 978-0-596-55447-7.
- ^ "JavaScript data types and data structures – JavaScript | MDN". Developer.mozilla.org. 2017-02-16. Retrieved 2017-02-24.
- ^ "ECMAScript Language – test262". Test262.ecmascript.org. Archived from the original on 2011-05-14. Retrieved 2013-10-31.
- ^ "tc39/test262". GitHub. January 24, 2020. Retrieved January 29, 2020.
- ^ ES5 is the baseline for this test suite. The conformance rate for other editions reflects support for new features only, not a comprehensive score.
- ^ "ECMAScript 5 compatibility table". kangax.github.io. Retrieved 2018-11-08.
- ^ "ECMAScript 6 compatibility table". kangax.github.io. Retrieved 2018-11-08.
- ^ a b "ECMAScript 2016+ compatibility table". kangax.github.io. Retrieved 2018-11-08.
- ^ Composite score that includes new features from ES7 through next edition drafts
External links[edit]
ISO standards[edit]
ECMA standards[edit]
- ECMA-262
- ECMA-262 ECMAScript Language Specification 3rd edition (December 1999)
- ECMAScript Language Specification, Edition 3 Final, 24-Mar-00
- 4th Edition (overview): PDF
- 4th Edition (final draft): HTML, PDF
- ECMA-262 ECMAScript Language Specification 5th edition (December 2009)
- 5.1 Edition / June 2011: HTML, PDF
- 6th Edition / June 2015 (ECMAScript 2015 Language Specification): HTML, PDF
- 7th Edition / June 2016 (ECMAScript 2016 Language Specification): HTML, PDF
- 8th edition, June 2017 (ECMAScript 2017 Language Specification): HTML, PDF
- 9th edition, June 2018 (ECMAScript 2018 Language Specification): HTML,PDF
- 10th edition, June 2019 (ECMAScript 2019 Language Specification): HTML,PDF
- 11th edition, June 2020 (ECMAScript 2020 Language Specification): HTML,PDF
- 12th edition, June 2021 (ECMAScript 2021 Language Specification): HTML,PDF
- ECMA-290 ECMAScript Components Specification (June 1999)
- ECMA-327 ECMAScript 3rd Edition Compact Profile (June 2001)
- ECMA-357 ECMAScript for XML (E4X) Specification (June 2004)
- Computer-related introductions in 1997
- C programming language family
- Computer standards
- Dynamically typed programming languages
- Ecma standards
- JavaScript dialect engines
- JavaScript programming language family
- Object-based programming languages
- Programming languages with an ISO standard
- Prototype-based programming languages
- Scripting languages
- Source-to-source compilers