Web Development

JavaScript ES2024 Features: What's New and How to Use Them

Discover the latest JavaScript ES2024 features including Array grouping, Promise.withResolvers(), and more. Learn practical implementations.

Md. Rony Ahmed · 10 min read
JavaScript ES2024 Features: What's New and How to Use Them

ES2024: JavaScript's Latest Features



ECMAScript 2024 brings exciting new features to JavaScript. Let's explore what's new and how to use them.

Array Grouping



Finally, native array grouping without libraries:

const inventory = [
  { name: 'apples', type: 'fruit', quantity: 5 },
  { name: 'bananas', type: 'fruit', quantity: 10 },
  { name: 'carrots', type: 'vegetable', quantity: 8 },
];

const grouped = Object.groupBy(inventory, item => item.type);
// { fruit: [...], vegetable: [...] }


Promise.withResolvers()



Create promise resolve/reject functions cleanly:

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

// Use resolve/reject anywhere
setTimeout(() => resolve('Done!'), 1000);

const result = await promise;


RegExp v Flag



Unicode property escapes with set notation:

const regex = /[\\p{Script=Greek}&&\\p{Letter}]/v;
regex.test('α'); // true
regex.test('1'); // false


ArrayBuffer Resize



Dynamic array buffer sizing:

const buffer = new ArrayBuffer(8, { maxByteLength: 16 });
buffer.resize(12);
console.log(buffer.byteLength); // 12


Key Takeaways



1. Object.groupBy() simplifies array grouping
2. Promise.withResolvers() cleans up async patterns
3. These features are already in modern browsers