New features in ES2023 JavaScript

Home » Programming » New features in ES2023 JavaScript

New features in ES2023 JavaScript

ES2023 is the version of ECMAScript released in this year. Checkout features that have been incorporated and could be used in our Javascript projects.

Features of ES2023

    • Find array from the last
    • Hashbang Grammer
    • Symbol as WeakMap keys
    • Change array by copy

 

Find array from the last

The findLast() method will allow us to find element from the last to first of the array based on a condition.

findLast()

 

The findLastIndex() method finds the index of the last element that satisfies a condition.

 

 

Hashbang Grammer

This feature would enable us to use Hashbang in some CLI. Hashbang is represented by #! and is a special line at the beginning of the script that tells the operating system which interpreter to use when executing the script.

#!/usr/bin/env node this line would invoke a Node.js source file directly, as an executable in its own.

 

Symbols as WeakMap keys

This allows using unique Symbols as keys. Objects are used as keys for WeakMaps because they share the same identity aspect. Symbol is the only primitive type in ECMAScript that allows unique values therefor using Symbol as key instead of creating a new object with WeakMap.

 

Change Array by Copy

The toReversed() method as a safe way to reverse an array without altering the original array. The difference between the new toReversed() method and the old reverse() method is that the new method creates a new array, keeping the original array unchanged, while the old method altered the original array.

 

The toSorted() method as a safe way to sort an array without altering the original array. The difference between the new toSorted() method and the old sort() method is that the new method creates a new array, keeping the original array unchanged, while the old method altered the original array.

 

The toSpliced() method as a safe way to splice an array without altering the original array. The difference between the new toSpliced() method and the old splice() method is that the new method creates a new array, keeping the original array unchanged, while the old method altered the original array.

 

The with() method as a safe way to update elements in an array without altering the original array.

 

 

To see which ES2023 features are supported by Nodejs, visit https://node.green/. You can also checkout the features of ES2022.