ECMAScript 2023

JavaScript version number

Early ECMAScript versions were named with numbers: ES5 and ES6.

Starting from 2016, the versions are named after the year: ES2016, 2018, 2020……

Version 14, that is, ECMAScript 2023, was released in June 2023.

New features in ES2023

Warning

These features are relatively new.

Older browsers may need alternative code (Polyfill).

JavaScript Array findLast() Method

ES2023 added findLast() This method starts from the end of the array and returns the value of the first element that meets the condition.

Example

const temp = [27, 28, 30, 40, 42, 35, 30];
let high = temp.findLast(x => x > 40);

Try It Yourself

JavaScript Array findLastIndex() Method

findLastIndex() This method finds the index of the last element that meets the condition.

Example

const temp = [27, 28, 30, 40, 42, 35, 30];
let pos = temp.findLastIndex(x => x > 40);

Try It Yourself

JavaScript Array toReversed() Method

ES2023 added Array toReversed() method, which is a safe way to reverse an array without changing the original array.

new toReversed() method compared to the old reverse() The difference between the methods is that the new method creates a new array without changing the original array, while the old method changes the original array.

Example

const months = ["Jan", "Feb", "Mar", "Apr"];
const reversed = months.toReversed();

Try It Yourself

JavaScript Array toSorted() Method

ES2023 added Array toSorted() method, which is a safe way to sort an array without changing the original array.

new toSorted() method compared to the old sort() The difference between the methods is that the new method creates a new array without changing the original array, while the old method changes the original array.

Example

const months = ["Jan", "Feb", "Mar", "Apr"];
const sorted = months.toSorted();

Try It Yourself

JavaScript Array toSpliced() Method

ES2023 added Array toSpliced() method, which is a safe way to concatenate arrays without changing the original array.

new toSpliced() method compared to the old splice() The difference between the methods is that the new method creates a new array without changing the original array, while the old method changes the original array.

Example

const months = ["Jan", "Feb", "Mar", "Apr"];
const spliced = months.toSpliced(0, 1);

Try It Yourself

JavaScript Array with() method

ES2023 added Array with() method, as a safe way to update array elements without changing the original array.

Example

const months = ["Januar", "Februar", "Mar", "April"];
const new = months.with(2, "March");

Try It Yourself

JavaScript Shebang (#!)

Shebang is the hash sign (#) at the beginning of a script.#) and exclamation mark (!) combination (#!)

#!/usr/bin/env node

The above example tells the operating system to use the node program to run the script.

Now, you can use ./fileName.js to run JavaScript code instead of using node fileName.js.

#! Also known as sharp-exclamation (sharp-exclamation mark), hashbang (hash-bang), pound-bang (pound-bang) or hash-pling (hash pling).