ECMAScript 2023 has now been approved by ECMA International . ECMAScript, the standardized JavaScript language, was first published in 1997 and has grown to become one of the most widely used general-purpose programming languages in the world.
This Ecma standard defines the ECMAScript 2023 Language, the 14th edition of the ECMAScript language specification.
ECMAScript 2023, 14th edition, introduces the , , , and methods on
Array.prototype
and above ; adds support for comments at the beginning of files to better facilitate the executable of ECMAScript files; and allows Use most Symbols as keys.TypedArray.prototype
toSorted
toReversed
with
findLast
findLastIndex
Array.prototype
toSpliced
#!
The final proposal, published on GitHub by ECMA TC39, details four features that will be released this year:
Array find from last
This proposal adds and methods to the Array
and prototype . This is the same behavior as Array.prototype.find and Array.prototype.findIndex , but will iterate from the last to the firstTypedArray
findLast()
findLastIndex()
const array = [{ value: 1 }, { value: 2 }, { value: 3 }, { value: 4 }]; array.find(n => n.value % 2 === 1); // { value: 1 } array.findIndex(n => n.value % 2 === 1); // 0 // ======== Before the proposal =========== // find [...array].reverse().find(n => n.value % 2 === 1); // { value: 3 } // findIndex array.length - 1 - [...array].reverse().findIndex(n => n.value % 2 === 1); // 2 array.length - 1 - [...array].reverse().findIndex(n => n.value === 42); // should be -1, but 4 // ======== In the proposal =========== // find array.findLast(n => n.value % 2 === 1); // { value: 3 } // findIndex array.findLastIndex(n => n.value % 2 === 1); // 2 array.findLastIndex(n => n.value === 42); // -1
Hashbang Grammar
A hashbang, also known as a shebang, is a sequence of characters at the beginning of an executable script that defines the program's interpreter to run. When the Unix kernel's program loader executes a JavaScript program, the host strips off the hashbang to generate valid source before passing it to the engine. The Hashbang Grammar proposal standardizes how this is done.
#!/usr/bin/env node // in the Script Goal 'use strict'; console.log(1);
#!/usr/bin/env node // in the Module Goal export {}; console.log(1);
Symbols as WeakMap keys
This proposal extends the WeakMap API to allow the use of unique Symbols as keys.
const weak = new WeakMap(); // Pun not intended: being a symbol makes it become a more symbolic key const key = Symbol('my ref'); const someObject = { /* data data data */ }; weak.set(key, someObject);
Change Array by Copy
Additional methods are provided on and that implement mutations to an array by returning a new copy with the mutations Array.prototype
.TypedArray.prototype
const sequence = [1, 2, 3]; sequence.toReversed(); // => [3, 2, 1] sequence; // => [1, 2, 3] const outOfOrder = new Uint8Array([3, 1, 2]); outOfOrder.toSorted(); // => Uint8Array [1, 2, 3] outOfOrder; // => Uint8Array [3, 1, 2] const correctionNeeded = [1, 1, 3]; correctionNeeded.with(1, 2); // => [1, 2, 3] correctionNeeded; // => [1, 1, 3]
For details, you can view: