ECMA (European Computers Manufacturers Association)
ECMA has categorized various elements or parameters into classes for ease of understanding. These include the following:
The New ECMA license
The ECMA license helps in providing a definitive document and location for a particular set of work on a given standard as per the SOP. It gets done with the intention of preventive forking. For developers, Mozilla wants to make it easy by actively participating in web evolution. The initiative introduces an alternate source for all ECMA International Specifications. The latest version, ECMAScript 2022, got approved by ECMA in the previous weeks.
New features in ECMAScript 2022
Public and Private Instance Fields
Introducing to the Constructor was the previously standard approach that declared a member-field inside the Class Keywords. The newest ECMAScript specifications define the number of fields inline as part of the class-body. Various listings get done to define the public and private instance fields.
For example, Listing 1 defines a class song using the class Keyword, with the class containing two members that are title and artist. Here, the artist gets prefixed with a hash (#) symbol that makes it private. The constructor accesses this.#artist with hash (#) prefix to stop the program from over-writing the field with a public member. After these procedures, an instance gets defined that illuminates the song class through setting both public and private instance fields via the Constructor. The output of the fields then gets expressed via the console. Here, the point is that song1.artist is invisible to the outside world with undefined outputs. Private fields cannot be created in the Class later using assignments. Hence, overall this listing leads to the making of cleaner codes.
The hash (#) symbol used works as a prefix on various methods and accessors. This gets defined under listing 2 which deals with private instance methods and accessors.
RegExp Match Indices and Regex Group Indices
The RegExp match got upgraded to include more information about the matching groups. This particular information gets only included if the /d flag gets added to the regular expressions. It causes the Regex engine to include the start and end of all matching substrings. The flag helps with the indices property on the exec results, which contain a 2D Array. Here, the first dimension represents the match and the second dimension showcases the start and end of the match. In the case of the named groups, the indices have a member named groups. The first dimension here contains the name of the group. Code blocks 1,2,3, and 4 help in accessing the details of where groups get matched within a string.
The ECMAScript specifications include the ability to package various asynchronous modules. The Top-Level Await proposal showcase that when you import a module wrapped in await, the including module does not execute until all the awaits get fulfilled.
Ergonomic brand checks for private fields
The developers look for codes that are comfortable in the ergonomic private fields from within a class using the in Keyword.
It talks about Negative indexing with .at(), where the .at method gets a built-in indexable that support all negative indices.