Versions and Features of ECMAScript (ES) along with their release years
February 10, 2024 3:32 PM
Here are the versions of ECMAScript (ES) along with their release years:
- ES1: Released in 1997
- ES2: Released in 1998
- ES3: Released in 1999
- ES4: Abandoned
- ES5: Released in 2009
- ES5.1: Released in 2011
- ES6/ES2015: Released in 2015
- ES2016: Released in 2016
- ES2017: Released in 2017
- ES2018: Released in 2018
- ES2019: Released in 2019
- ES2020: Released in 2020
- ES2021: Released in 2021
Each version brought new features and improvements to the language.
Some notable features introduced in ES6/ES2015
ES6, also known as ES2015, introduced several significant features and improvements to JavaScript. Here are some of the most notable ones:
- Arrow Functions: A new way to write functions with a shorter syntax.
- Classes: A syntax for defining classes and inheritance (syntactic sugar over JavaScript's existing prototype-based inheritance).
- Promises: An API for asynchronous programming and handling values that may not have been computed yet.
- Modules: A way to split code into reusable modules.
- Template Literals: A new syntax for strings that includes interpolation and multi-line strings.
- Default Parameters: The ability to set default values for function parameters.
- Destructuring Assignment: A syntax that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.
- Rest and Spread Operators: The rest operator (
...
) allows a function to handle an arbitrary number of arguments as an array. The spread operator allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected. - Enhanced Object Literals: This enhancement allows actual classes with a minimal amount of syntax in your JavaScript programs, including a shorthand for
obj = { x, y }
and methods in an object literal likeobj = { foo() { return "bar"; } }
. - Generators: A special kind of function that can be paused and resumed, which makes asynchronous programming easier.
- Map and Set: New data structures that make it easier to manage collections of data.
- Symbols: A new primitive type for unique identifiers.
Some notable features introduced in ES2016 and later versions:
ES2016 (ES7):
- Array.prototype.includes: A method that determines whether an array includes a certain value among its entries.
- Exponentiation Operator (
**
): A new arithmetic operator used to raise the first operand to the power of the second operand.
ES2017 (ES8):
- Async/Await: A new way to handle asynchronous operations, making it simpler to write asynchronous code in a synchronous manner.
- Object.values/Object.entries: Methods for easier extraction of values and entries from objects.
- String padding:
padStart()
andpadEnd()
methods to help pad a string with another string until it reaches the given length. - Trailing commas in function parameter lists and calls: This allows for cleaner git diffs when parameters are added or removed.
ES2018 (ES9):
- Rest/Spread Properties: Allows objects to use rest and spread properties just like arrays do.
- Asynchronous Iteration: Provides a way to iterate over data that comes asynchronously.
- Promise.prototype.finally: A method on Promises that always gets called, regardless of whether the Promise was resolved or rejected.
ES2019 (ES10):
- Array.prototype.{flat,flatMap}:
flat()
is used to flatten arrays andflatMap()
is a method that first maps each element using a mapping function, then flattens the result into a new array. - Object.fromEntries: Transforms a list of key-value pairs into an object.
- String.prototype.{trimStart,trimEnd}: These methods remove whitespace from the beginning and end of a string respectively.
ES2020 (ES11):
- BigInt: A new numeric primitive in JavaScript, allowing the representation and manipulation of integers larger than
Number.MAX_SAFE_INTEGER
. - Dynamic Import: Allows scripts to be loaded on demand.
- Nullish Coalescing Operator (
??
): A logical operator that returns its right-hand side operand when its left-hand side operand isnull
orundefined
, and otherwise returns its left-hand side operand. - Optional Chaining Operator (
?.
): Allows you to read the value of a property located deep within a chain of connected objects without having to check that each reference in the chain is valid.
ES2021 (ES12):
- Promise.any: Takes an iterable of Promise objects and, as soon as one of the promises in the iterable fulfils, returns a single promise that resolves with the value from that promise.
- String.prototype.replaceAll: Returns a new string with all matches of a pattern replaced by a replacement.
- Logical Assignment Operators (
&&=
,||=
,??=
): These operators combine logical operations and assignment in a single step. - Numeric Separators: Improve readability and clarity of numeric literals. For example, you can write
1_000_000
instead of1000000
.
Some notable features introduced in ES2022 (ES13)
As of the time of this response, the ES2022 (or ES13) specification is still in the proposal stage and has not been finalized. However, here are some features that are currently at Stage 4 (the final stage) and are expected to be included in ES2022:
- Array.prototype.at(): This method takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.
- Class Fields (Public and Private): This feature introduces a new way to declare fields in a class, both public and private. Public fields are declared using a simple variable declaration like
field = value;
. Private fields are declared using a hash#
prefix like#field = value;
. - Static Class Fields and Static Private Methods: This feature allows declaring static public fields, static private fields, and static private methods in a class.
- Decorators: A proposal to add a decorator syntax for modifying JavaScript classes, properties, and object literals. Decorators provide a way to add both annotations and a meta-programming syntax for class declarations and members.
- Ergonomic brand checks for Private Fields: This feature introduces a new syntax for checking if an object has a certain private field.
- Legacy RegExp features in JavaScript: This proposal aims to standardize some features and behaviors of RegExp objects in web reality as a legacy RegExp features in the JavaScript specification.
- Intl Enumeration API: An API that allows programs to determine which locales are available in the runtime’s locale data set.
This list is subject to change as the ES2022 specification is finalized
Comments