ECMAScript 2023
JavaScript Version Numbers
The previous versions of ECMAScript were identified by numbers, namely ES5 and ES6.
Starting in 2016, the versions are named based on the year they were released: ES2016, 2018, 2020, and so on.
The 14th version of ECMAScript, named ECMAScript 2023, got released in June 2023.
New Features in ES2023
- Array findLast()
- Array findLastIndex()
- Array toReversed()
- Array toSorted()
- Array toSpliced()
- Array with()
- #! (Shebang)
Warning
These characteristics are quite recent.
Outdated web browsers might require a different code, commonly known as a Polyfill.
JavaScript Array findLast() Method
In ES2023, a new method called findLast() was introduced. This method works by searching from the end of an array and retrieving the value of the first element that meets a specified condition.
JavaScript Array findLastIndex() Method
The findLastIndex() function locates the position of the final element that meets a specific condition.
JavaScript Array toReversed() Method
In ES2023, a new method called toReversed() was introduced. It provides a secure way to reverse an array without changing the original array.
The new method toReversed() is distinct from the old reverse() method. When using the new method, it generates a new array, leaving the original array unaffected. On the other hand, the old method modified the original array.
JavaScript Array toSorted() Method
In ES2023, a new method called toSorted() was introduced. This method allows you to safely sort an array without changing the original array.
The new toSorted() method is distinct from the old sort() method in how it handles arrays. Unlike the old method, which modifies the original array, the new method generates a fresh array without changing the original one.
JavaScript Array toSpliced() Method
In ES2023, a new method called toSpliced() was introduced. It provides a secure way to splice an array without making changes to the original array.
The new toSpliced() method is distinct from the old splice() method. In simple terms, the new method makes a fresh array without changing the original one, whereas the old method modified the original array.
JavaScript Array with() Method
In ES2023, a new method called Array with() was introduced. It provides a secure way to modify elements in an array without changing the original array.
#! JavaScript Shebang
A Shebang is a combination of a number sign and an exclamation mark (#!) placed at the start of a script.
The sample code instructs the operating system to employ the "node" program for executing the script.
Now, you can execute JavaScript code using ./fileName.js
instead of the previous node fileName.js
command.
#! is known by various names such as sharp-exclamation, hashbang, pound-bang, or hash-pling.
#!/usr/bin/env node