An overview of the new ES12 specs

The new ES12 specs are finally here. Specs? JavaScript is indeed not an open-source language. It’s a language written following the ECMAScript standard specifications. The TC39 committee is in charge of discussing and approving new features. Who are they?

“ECMA International’s TC39 is a group of JavaScript developers, implementers, academics, and more, collaborating with the community to maintain and evolve the definition of JavaScript.” — TC39.es

Their release process is composed of five stages. Since 2015, they have been doing yearly releases. They normally happen around springtime. This year’s release will be proposed for approval on June 9.

There are two ways to refer to any ECMAScript release:

  • By its year: This new release will be ES2021.
  • By its iteration number: This new release will be the 12th iteration, so it can be referred to as ES12.

So what is new in this release? What features can we get excited about?

replaceAll

A new function has been added to the String prototype. Prior to this addition, it was not possible to replace all the instances of a substring without the use of regex.

Before ES12:

// using Regex to replace
'1 2 1 2 1 2'.replace(new RegExp('2', 'g'), '0');
// another option
'1 2 1 2 1 2'.replace(/2/g, '0');

// we can create our own helper
function replaceAll(str, find, replace) {
 return str.replace(new RegExp(find, 'g'), replace);
}

#programming #javascript #react #web-development

JavaScript ES2021: A Look at the New Features
1.55 GEEK