Frontend Development 7 min read

Explore ES2024: 5 Game-Changing JavaScript Features You Must Know

The article reviews five major ES2024 (ES15) JavaScript enhancements—including native groupBy, Promise.withResolvers, adjustable Buffer, Atomics.waitAsync, and a new regex v flag—explaining their usage, benefits, and code examples for modern web development.

Code Mala Tang
Code Mala Tang
Code Mala Tang
Explore ES2024: 5 Game-Changing JavaScript Features You Must Know

Array native group-by method

Object.groupBy() and Map.groupBy() are introduced in ES2024, providing native grouping capabilities that reduce the need for utility libraries like Lodash. Currently only Object and Map support the groupBy operation.

Object.groupBy illustration
Object.groupBy illustration
Map.groupBy illustration
Map.groupBy illustration

Promise.withResolvers

The new Promise.withResolvers() API simplifies Promise creation, eliminating the need for manual closure patterns or extra NPM dependencies.

Promise.withResolvers usage
Promise.withResolvers usage

It enables easy external control of Promise resolution, improving lazy‑loading strategies and overall page performance.

Promise resolution example
Promise resolution example

Buffer performance upgrade

Buffers act as temporary storage in pipelines such as file processing, video streaming, and producer‑consumer queues. Previously, expanding a buffer required copying data to a larger allocation, which was costly for large data volumes.

Buffer pipeline illustration
Buffer pipeline illustration

ES2024 introduces adjustable array buffers that can grow without full copying, dramatically improving performance for high‑throughput pipelines.

Adjustable buffer diagram
Adjustable buffer diagram

Async upgrade – Atomics.waitAsync

The new Atomics.waitAsync() method allows asynchronous waiting on a shared memory location without blocking the main thread, facilitating efficient coordination between Web Workers.

Atomics.waitAsync diagram
Atomics.waitAsync diagram

Example usage:

<code>// Main thread
const sharedBuffer = new SharedArrayBuffer(4);
const sharedUint32 = new Uint32Array(sharedBuffer);
sharedUint32[0] = 0;
const worker = new Worker('worker.js');
worker.postMessage({ sharedBuffer });
setTimeout(() => { sharedUint32[0] = 1; }, 1000);

// worker.js
onmessage = async ({ data }) => {
  const { sharedBuffer } = data;
  const sharedUint32 = new Uint32Array(sharedBuffer);
  while (true) {
    const value = Atomics.waitAsync(sharedUint32, 0, 0);
    if (value === 1) {
      console.log('Value has changed to 1!');
      break;
    }
  }
  console.log('Processing data...');
};
</code>

The worker waits on sharedUint32[0] until the main thread updates it, then resumes execution.

Regex upgrade – v flag for set operations

ES2024 adds a new v flag to regular expressions, enabling Unicode set operations that can match expanding character sets such as emojis, accented letters, and various symbols.

Unicode regex with v flag
Unicode regex with v flag

Typical character‑set syntax like [abc] , [^abc] , and [a-z] remains, but the new syntax introduces additional set‑operation operators (illustrated in the image).

Conclusion

ES2024 represents a major leap for JavaScript, delivering native capabilities that simplify code, enhance performance, and expand expressive power for modern web development.

frontendJavaScriptWeb DevelopmentNew FeaturesES2024
Code Mala Tang
Written by

Code Mala Tang

Read source code together, write articles together, and enjoy spicy hot pot together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.