ECMAScript 2024

JavaScript version number

Early ECMAScript versions were named by number: ES5 and ES6.

Starting from 2016, versions are named by year: ES2016, 2018, 2020...

The 15th version, ECMAScript 2024, was released in July 2024.

New features in ES2024

Warning

These features are relatively new.

Older browsers may require alternative code (Polyfill).

JavaScript Object.groupBy()

Example

// Create an array
const fruits = [
  {"name":"apples", "quantity":300},
  {"name":"bananas", "quantity":500},
  {"name":"oranges", "quantity":200},
  {"name":"kiwi", "quantity":150}
];
// Callback function for grouping elements
function myCallback({ quantity }) {
  return quantity > 200 ? "ok" : "low";
}
// Group by quantity
const result = Object.groupBy(fruits, myCallback);

Try It Yourself

Description

Object.groupBy() The method groups the elements of the object based on the string value returned by the callback function.

Object.groupBy() The method will not change the original object.

Note:

The elements in the original object and returned object are the same.

Changes to the original object or returned object will be reflected in both at the same time.

JavaScript Map.groupBy()

Example

// Create an array
const fruits = [
  {"name":"apples", "quantity":300},
  {"name":"bananas", "quantity":500},
  {"name":"oranges", "quantity":200},
  {"name":"kiwi", "quantity":150}
];
// Callback function for grouping elements
function myCallback({ quantity }) {
  return quantity > 200 ? "ok" : "low";
}
// Group by quantity
const result = Map.groupBy(fruits, myCallback);

Try It Yourself

Description

Map.groupBy() The method groups the elements of the object based on the string value returned by the callback function.

Map.groupBy() The method will not change the original object.

Note:

The elements in the original object and returned object are the same.

Changes to the original object or returned object will be reflected in both at the same time.

Object.groupBy() vs Map.groupBy()

Object.groupBy() and Map.groupBy() The difference is:

Object.groupBy() Group elements into a JavaScript object.

Map.groupBy() Group elements into a Map object.

JavaScript Temporal.PlainDate()

Example

const date = Temporal.PlainDate(2024, 5, 1);

Try It Yourself

JavaScript Temporal.PlainTime()

Example

const date = new Temporal.PlainTime(10, 30);

Try It Yourself

JavaScript Temporal.PlainMonthDay()

Example

const date = new Temporal.PlainMonthDay(5, 1);

Try It Yourself

JavaScript Temporal.PlainYearMonth()

Example

const date = new Temporal.PlainYearMonth(2024, 5);

Try It Yourself