Skip to content Paweł Grzybek

What's new in ECMAScript 2023

After reading notes from the last TC39 meeting, it looks like the list of new features coming to JavaScript is already known. The final version of the ECMAScript specification is expected to be published at the end of June.

Last and most important thing is that we are cutting ES2023. We are freezing it, or rather we have frozen it, I should say. We are not expecting any more significant editorial changes. There will be at least a couple very small editorials tweaks that will land but nothing large.

Let me share the list of all the new features that reached stage 4 and are expected to be included in the upcoming ECMAScript version. Exactly what I did in 2022, 2021, 2020, 2019, 2018, 2017 and 2016.

Array find from last

Array find from the last proposal by Wenlu Wang adds findLast() and findLastIndex() methods on Array and TypedArray prototype. They do the same thing as find() and findIndex() but in reverse order. Both methods are handy and let us skip creating temporary duplicates, mutations and confusing index substractions.

const isEven = (number) => number % 2 === 0;
const numbers = [1, 2, 3, 4];

// from first to the last lookup
// 2
// 1

// from last to the first lookup
// 4
// 3

Hashbang Grammar

Hashbang, also known as a shebang is a sequence of characters at the beginning of an executable script that defines the interpreter for the program to be run on. When the Unix kernel’s program loader executes a JavaScript program, the host strips the hashbang to generate a valid source before passing it down to the engine. Hashbang Grammar proposal by Bradley Farias standardizes how it is done.

#!/usr/bin/env node

console.log('hi 👋');

Symbols as WeakMap keys

In JavaScript, Objects and Symbols are guaranteed to be unique and cannot be re-created, which makes them both great candidates for the WeakMap keys. Previous versions or specifications allowed only Objects to be used that way, but luckily Symbols as WeakMap keys proposal by Daniel Ehrenberg, Richard Button, Robin Ricard, Leo Balter, Rick Waldron and Caridy Patiño adds non-registered Symbols to the list of allowed keys.

const weak = new WeakMap();
const key = Symbol("ref");
weak.set(key, "ECMAScript 2023");

// ECMAScript 2023

Change Array by Copy

The reverse(), sort() and splice() methods on Array.prototype mutate the array in place. Change Array by Copy proposal by Ashley Claymore and Robin Ricard adds equivalents of those methods that return a new copy — toReversed(), toSorted() and toSpliced(). This proposal also adds a with() method that returns a new array with the element at the given index replaced with the given value to avoid mutations in place using bracket notation.

const original = [1, 2, 3, 4];
const reversed = original.toReversed();

// [ 1, 2, 3, 4 ]

// [ 4, 3, 2, 1 ]
const original = [1, 3, 2, 4];
const sorted = original.toSorted();

// [ 1, 3, 2, 4 ]

// [ 1, 2, 3, 4 ]
const original = [1, 4];
const spliced = original.toSpliced(1, 0, 2, 3);

// [ 1, 4 ]

// [ 1, 2, 3, 4 ]
const original = [1, 2, 2, 4];
const withThree = original.with(2, 3);

// [ 1, 2, 2, 4 ]

// [ 1, 2, 3, 4 ]


  • P

    Thanks for the briefing! Nice and to the point.

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!
  • A

    Thanks for sharing

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!
  • P
    Pippo Baudo

    Still waiting for pipeline operator :/

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!

Leave a comment

👆 you can use Markdown here

Your comment is awaiting moderation. Thanks!