Wednesday, 17 April, 2024 UTC


Summary

The ECMAScript specification is like a portrait of the JavaScript language that is repainted every year. As is typical of modern JavaScript, the spec and real-world practice move in tandem. The newest version of the spec, ECMAScript 2024, includes seven new JavaScript features and is expected to be finalized in June. This article introduces four of the new features that are already available in browsers and server-side environments, and ready for you to use today:
  • Promise.withResolvers is a powerful mechanism for managing asynchronous operations when external control over resolution and rejection is necessary.
  • Object.groupBy and Map.groupBy let you organize collections based on key properties.
  • Atomics.waitAsync facilitates safe communication and synchronization between worker threads.
  • String.isWellFormed and String.toWellFormed add valuable tools for handling user input and network data.
Promise.withResolvers
Let’s start with the new static method on Promise, called withResolvers(). JavaScript promises give us various ways to deal with asynchronous operations. The withResolvers() method is used to create the three parts of a Promise: the Promise itself and the resolve() and reject() functions. 
To read this article in full, please click here