JavaScript 2024
JavaScript Basics

JavaScript 2024

ECMAScript 2024 Overview

JavaScript continues to evolve with new versions named by year since 2016. The latest, ECMAScript 2024, published in July 2024, marks the 15th edition of the standard.

New Features in ES2024

  • Object.groupBy() and Map.groupBy(): These methods categorize collections of objects into groups based on a callback function's results.
  • Temporal API: Introduces several new objects for handling dates and times without the complexities of the older Date object.

Code Examples and Descriptions


Groups array elements into an object based on callback function outcomes:

const fruits = [  
{name: "apples", quantity: 300},  
{name: "bananas", quantity: 500}, 
{name: "oranges", quantity: 200},  
{name: "kiwi", quantity: 150}];‍
function classifyByQuantity({ quantity }) {  return quantity > 200 ? "sufficient" : "low";}
const groupedFruits = Object.groupBy(fruits, classifyByQuantity);‍

This method groups items without modifying the original array, but changes to the objects will reflect across both the original and grouped objects.


Similar to Object.groupBy(), but categorizes items into a Map object, allowing more complex structures and potentially better performance with large datasets:

const groupedFruitsMap = Map.groupBy(fruits, classifyByQuantity);

Temporal API

Introduces more intuitive and reliable ways to handle dates and times:

  • Temporal.PlainDate(): Represents a calendar date without time or timezone
    const plainDate = new Temporal.PlainDate(2024, 5, 1);

  • Temporal.PlainTime(): Represents time of day without a date or timezone

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

  • Temporal.PlainMonthDay(): Represents a recurring day of the month without a specific year.
    const monthDay = new Temporal.PlainMonthDay(5, 1);

  • Temporal.PlainYearMonth(): Represents a specific month of a specific year
    const yearMonth = new Temporal.PlainYearMonth(2024, 5);

These new features in ECMAScript 2024 provide powerful tools for data structuring and date-time manipulation, enhancing JavaScript's utility for developers. As these features are recent, older browsers may require polyfills for compatibility.

Take a look into your desired course