ECMAScript 2022 officially released

On June 22, 2022, the 123rd Ecma Congress ratified the ECMAScript 2022 language specification , which means it is officially a standard. Every year since 2015, TC39 team members have come together to discuss available proposals and publish accepted proposals, and this year marks the 13th edition of ECMAScript.

What’s New in ECMAScript 2022

Here are a few listed below:

Top-level Await

Top-level await allows the await keyword to be used outside of async functions. It allows modules to act as large asynchronous functions, and with top-level await, these ECMAScript modules can wait for resources to load, so that other modules importing these modules wait for the resources to load before executing their code.

.at() method of index value corresponding value

This function lets us read the element at the given index, it can accept negative indices to read the element from the end of the given data type. The data types that support this feature are the following:

  • String;

  • Array;

  • All typed array classes: Uint8Array, etc.

Object.hasOwn()

Before ES2022, Object.prototype.hasOwnProperty() could be used to check if a property belonged to an object. The Object.hasOwn attribute is a more concise and reliable way to check if a property is set directly on an object.

error.cause

Analyzing the error and its subclasses lets us specify the reason behind the error.

RegExp match index

In addition to g, i, the new d flag to regular expressions will generate a match object that records the start and end of each group capture.

class new member

Public class fields allow us to add instance properties to the class definition using the assignment operator (=).

Private class fields, methods will be defined using the hash # prefix.

ES 2022 provides a way to declare static class fields in JavaScript using the static keyword.

Like private instance fields and methods, static private fields and methods are defined using the hash # prefix.

This specification provides an elegant way to evaluate static initialization code blocks during class declaration/definition, with access to the private fields of the class.

About ECMAScript

The full name of ES is ECMAScript , a scripting language specification defined by ECMA International (formerly the European Computer Manufacturers Association) in the standard ECMA-262. Since 2015, there has been a version every year, and ES2022 is already the thirteenth version. The JavaScript we commonly use is the implementation and extension of the ECMA-262 standard.

ECMAScript was designed by Technical Committee 39 (TC39) of the standards organization Ecma International.

TC39 is dedicated to:

  • Maintains and updates the standard for the ECMAScript programming language.

  • A standard for identifying, developing, and maintaining libraries that extend the functionality of ECMAScript.

  • Develop test suites that can be used to verify proper implementation of these standards.

  • Contribute selected standards to ISO/IEC JTC 1 committees.

  • Evaluate and consider suggestions for complementary or additional techniques.

Reference link:

https://www.aisoutu.com/a/2375789

https://2ality.com/2022/06/ecmascript-2022.html

The text and pictures in this article are from InfoQ

loading.gif

This article is reprinted from https://www.techug.com/post/ecmascript-2022-officially-releaseda48503e159acc4a91708/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment