Michał Matłoka

4 NEW FEATURES COMING TO JS IN 2023

implementation

==

standard

JavaScript

==

ECMAScript

ECMAScript over the years

edition 1 June 1997
edition 2 June 1998
edition 3 December 1999
edition 4 👻
edition 5 December 2009
edition 6 / ES2015 June 2015
edition 7 / ES2016 June 2016
edition 8 / ES2017 June 2017
…and so on and so on… June 20xx

ECMAScript over the years

edition 1 June 1997
edition 2 June 1998
edition 3 December 1999
edition 4 👻
edition 5 December 2009
edition 6 / ES2015 June 2015
edition 7 / ES2016 June 2016
…and so on and so on… June 20xx
edition 14 / ES2023 June 2023!

Shipping proposal: Change array by copy

Support – all up-to-date browsers and runtimes, except Firefox and Samsung Internet

  • get reversed copy of array (equivalent of the in-place array.reverse()):

    array.toReversed() -> Array
  • get sorted copy of array (equivalent of the in-place array.sort(...)):

    array.toSorted(compareFn) -> Array
  • get copy of array with item(s) inserted in the middle (equivalent of the in-place array.splice(...)):

    array.toSpliced(start, deleteCount, ...items) -> Array
  • get copy of array with nth element replaced (equivalent of the in-place array[index] = value):

    array.with(index, value) -> Array

Shipping proposal: Array find from last

Support – all up-to-date browsers and runtimes

  • array.find(...), but search from the end, looking for the last matching element:

    array.findLast(predicateFn) -> ArrayElement
  • array.findIndex(...), but search from the end, looking for the last matching element:

    array.findLastIndex(predicateFn) -> ArrayElement

Shipping proposal: Symbols as WeakMap keys

Support – all up-to-date browsers and runtimes, except Firefox and Samsung Internet

const weakMap = new WeakMap()
// A WeakMap is a Map where the keys are garbage-collectible
const alwaysWorkedAsKey = {}
const didNotWorkAsKey = Symbol('foo')
const valueObject = { /* data data data */ }

weakMap.set(alwaysWorkedAsKey, valueObject) // ✅
weakMap.set(didNotWorkAsKey, valueObject) // ❌

Shipping proposal: Hashbang grammar

Support – all up-to-date browsers and runtimes

#!/bin/bash

echo Hello world!

Shipping proposal: Hashbang grammar

Support – all up-to-date browsers and runtimes

#!/usr/bin/env node

console.log("Hello world!")
$ ./script.js
# becomes the same as 
$ node script.js

🎉 Happy 2023!