bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/JavaScript/Debugging, Projects, and Reference
JavaScript•Debugging, Projects, and Reference

ECMAScript 2023

New Features in JavaScript 2023

FeatureDescription
#! (Shebang)Tells the operating system which interpreter to use to execute the script

New Array Features in 2023

FeatureDescription
findLast()Returns the value of the last element that satisfies a condition
findLastIndex()Returns the index of the last element that satisfies a condition
toReversed()Reverses an array without altering the original array
toSorted()Sorts an array without altering the original array
toSpliced()Splices an array without altering the original array
with()Updates array elements without altering the original array

Browser Support

ECMAScript 2023 is supported in all modern browsers since July 2023 :

Chrome 110Edge 110Firefox 115Safari 16.4Opera 96
Feb 2023Feb 2023Jul 2023Mar 2023May 2023

JavaScript Array findLast() Method

ES2023 added the findLast() method that will start from the end of an array and return the value of the first element that satisfies a condition.

Example

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

JavaScript Array findLastIndex() Method

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

Example

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

JavaScript Array toReversed() Method

ES2023 added the Array 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.

Example

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

JavaScript Array toSorted() Method

ES2023 added the Array 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.

Example

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

JavaScript Array toSpliced() Method

ES2023 added the Array 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.

Example

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

JavaScript Array with() Method

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

Example

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

#! JavaScript Shebang

In operating systems, a shebang (also known as hashbang, pound-bang, sharp-exclamation or hash-pling) is a sequence of two characters: a number sign (#) and an exclamation mark (!).

#! at the beginning of a script tells the operating system what interpreter should be used to execute the script:

Example

#!
/usr/bin/env node

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

Now, you can run JavaScript code with ./fileName.js instead of node fileName.js .

Previous

Project - Modal Popup

Next

JavaScript Debugging Async

This chapter

Overview
32

Lessons

180m

Read time

1. JavaScript Errors2. JavaScript Debugging3. JavaScript Statements4. Project - localStorage Counter5. ECMAScript 20266. JavaScript Silent Errors7. JavaScript Debugging Console8. JavaScript Reserved Words9. Project - Event Listener10. ECMAScript 202511. JavaScript Error Statements12. JavaScript Debugging Breakpoints13. JavaScript Operator Precedence14. Project - To-Do List15. ECMAScript 202416. JavaScript Debugging Errors17. Project - Modal Popup18. ECMAScript 202319. JavaScript Debugging Async20. Project - Form Validation21. ECMAScript 202222. ECMAScript 202123. ECMAScript 202024. ECMAScript 201925. ECMAScript 201826. ECMAScript 201727. ECMAScript 201628. Javascript 2015 (ES6)29. JavaScript 2009 (ES5)30. JavaScript 1999 (ES3)31. JavaScript Versions32. JavaScript History

On this page

New Features in JavaScript 2023New Array Features in 2023Browser SupportJavaScript Array findLast() MethodJavaScript Array findLastIndex() MethodJavaScript Array toReversed() MethodJavaScript Array toSorted() MethodJavaScript Array toSpliced() MethodJavaScript Array with() Method#! JavaScript Shebang