Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JS 2023

JavaScript Version Numbers

Earlier ECMAScript versions were named by numbers, such as ES5 and ES6. Since 2016, versions have been named by year, like ES2016, ES2018, and ES2020. The 14th edition, ECMAScript 2023, was released in June 2023.

New Features in ES2023

  • Array findLast()
  • Array findLastIndex()
  • Array toReversed()
  • Array toSorted()
  • Array toSpliced()
  • Array with()
  • #! (Shebang)

JavaScript Array findLast() Method

ES2023 introduced the findLast() method, which begins searching from the end of an array and returns the value of the first element that meets a given condition.

Example

const temp = [27283040423530];
let high = temp.findLast(x => x > 40);

JavaScript Array findLastIndex() Method

The findLastIndex() method returns the index of the last element in an array that meets a specified condition.

Example

const temp = [27283040423530];
let pos = temp.findLastIndex(x => x > 40);

JavaScript Array toReversed() Method

ES2023 introduced the toReversed() method for arrays, providing a safe way to reverse an array without modifying the original.

 

Unlike the reverse() method, which alters the original array, toReversed() creates a new array with the reversed elements, leaving the original array unchanged.

Example

const months = [“Jan”“Feb”“Mar”“Apr”];
const reversed = months.toReversed();

JavaScript Array toSorted() Method

ES2023 introduced the toSorted() method for arrays, offering a safe way to sort an array without modifying the original.

 

Unlike the sort() method, which changes the original array, toSorted() creates a new sorted array, leaving the original array unchanged.

Example

const months = [“Jan”“Feb”“Mar”“Apr”];
const sorted = months.toSorted();

JavaScript Array toSpliced() Method

ES2023 introduced the toSpliced() method for arrays, providing a safe way to splice an array without modifying the original.

 

In contrast to the splice() method, which alters the original array, toSpliced() creates a new array with the changes, leaving the original array unchanged.

Example

const months = [“Jan”“Feb”“Mar”“Apr”];
const spliced = months.toSpliced(01);