What's New in ECMAScript 2024

ECMAScript 2024 brings exciting new features to JavaScript. Let's explore the most important additions.

Array Grouping

New methods for grouping array elements:

const products = [
  { name: 'Apple', category: 'fruit' },
  { name: 'Carrot', category: 'vegetable' },
  { name: 'Banana', category: 'fruit' }
];

const grouped = Object.groupBy(products, p => p.category);
// { fruit: [...], vegetable: [...] }

Promise.withResolvers()

Simplified promise creation:

const { promise, resolve, reject } = Promise.withResolvers();

// Use resolve/reject outside promise constructor
setTimeout(() => resolve('Done!'), 1000);

Temporal API (Stage 3)

Modern date/time handling:

const now = Temporal.Now.plainDateTimeISO();
const future = now.add({ days: 7, hours: 3 });

RegExp v Flag

Enhanced Unicode support:

const regex = /\p{Emoji}/v;
regex.test('😀'); // true

Top-Level Await in Modules

No more wrapper functions:

// module.js
const data = await fetch('/api/data').then(r => r.json());
export { data };

Well-Formed Unicode Strings

Better string handling:

'string'.isWellFormed(); // true
'\uD800'.isWellFormed(); // false

Conclusion

ES2024 continues JavaScript's evolution with practical, developer-friendly features. Start experimenting with these today!