ECMAScript Updation and Implementation Cycle
Last Updated :
22 Aug, 2022
ECMAScript is the specification of JavaScript and there are updates to this which come in the form of ES updates. Most of us are familiar with the ES6 update as it brought most of the modern JavaScript features that we know about. Part of the reason why the ES6 update was so big was that it was 6 years prior to the ES5 update coming out.
ES6 changed the way JavaScript was updated instead of being updated once in a while they changed it so the update could come on a yearly basis that is why the name of these updates has changed for the most part people use the year to represent the ES updates. These updates don't actually update the language itself all these updates do is update the ECMAScript. The ECMAScript basically describes how JavaScript should work and function. It's then up to the browser to implement these updates and changes. This is why sometimes a feature could be in JavaScript officially announced and released but a browser still doesn't support it because they might not have implemented this feature yet and vice-versa.
The TC39 process defines how an implementation of a feature goes from a proposal to actually getting implemented by the browsers. And it goes through multiple different stages.
Changes to the language are developed by way of a process that provides guidelines for evolving an addition from an idea to a fully specified feature, complete with acceptance tests and multiple implementations. There are five stages: a strawperson stage, and 4 “maturity” stages. The TC39 committee must approve acceptance for each stage.
Different proposal stages of the TC39 Process
Here are some of the most promising proposals
Class static initialization blocks: This proposal is currently at stage 4 of the process. Class static blocks provide a mechanism for additional static initialization during class definition evaluation. Declare block inside the body of a class allows you to write code that will run at the class setup time and set up the static fields. It allows us the flexibility to access the private fields.
Note: As of now, this feature has not been implemented by Safari, IE, or Opera and has a global usage percentage of 74.14%.
Syntax:
class C {
static {
// Statements
}
}
Let us look at the example below:
JavaScript
class GFG{
static #dateNow = new Date()
static time
static{
GFG.time = GFG.#dateNow.toISOString()
}
}
GFG.time
Output:
'2022-07-25T20:30:15.558Z'
Ergonomic brand checks for Private Fields: This proposal is currently at stage 4 of the process. To check if an object has a private field, and if that object doesn't have a private field, we can have some fallback behavior which might even be throwing a custom exception. This allows us to test if a private field exists in a certain class or not. We can use a try/catch block for resolving this issue, but doing so is not very intuitive:
JavaScript
class GFG {
#code;
static isGFG(obj) {
try {
obj.#code;
return true;
} catch {
return false;
}
}
}
Output:
undefined
This problem can be resolved by using the "in" keyword, like this:
JavaScript
class GFG {
#code
isGFG(gfg){
return #code in gfg;
}
}
Output:
undefined
RegExp Match Indices: This allows us to find the offsets of any match that happened on the RegExp substring. In simple terms it allows us to find the positions of the starting and ending points of each match in a RegExp substring. The results point to the input string.
Let us look at the example below for Numbered groups:
JavaScript
const match = /(e+)/d.exec('geeks');
match.indices[1];
Output:
(2) [1, 3]
Let us look at the example below for Named groups:
JavaScript
const match = /(?<gs>g+)(?<es>e+)/d.exec('ggggeeks');
match.indices.groups.gs;
match.indices.groups.es;
Output:
(2) [4, 6]
Similar Reads
New Features in ECMAScript 2021 Update
ECMAScript is a part of JavaScript language which is mostly used in web technology, building websites, or web apps. ECMAScript is growing as one of the world's most widely used general-purpose programming languages. It is majorly used in embedding with web browsers and is also adopted for server and
4 min read
How to terminate a script in JavaScript ?
To terminate a script in JavaScript, we have different approaches: Table of Content Using return Terminating a part of the ScriptThrowing an error on purposeUsing process.exit for Node.JS applicationsUsing clearInterval() methodMethod 1: Using return In order to terminate a section of the script, a
4 min read
Difference between TypeScript and CoffeeScript
JavaScript programming language conforms to the ECMAScript specification. It is a high-level scripting language introduced by Netscape in 1995 to be run on the client side of the web browser. It can insert dynamic text into HTML. Browserâs language is another name for JavaScript. TypeScript and Coff
4 min read
Difference between TypeScript and JavaScript
Ever wondered about the difference between JavaScript and TypeScript? If you're into web development, knowing these two languages is super important. They might seem alike, but they're actually pretty different and can affect how you code and build stuff online.In this article, we'll break down the
4 min read
How to use EcmaScript Modules in Node.js ?
Using ECMAScript Modules (ES Modules or ESM) in Node.js allows you to take advantage of modern JavaScript syntax for organizing and managing your code. ECMAScript Modules provide a more structured and standardized way to work with modules compared to CommonJS, which has been traditionally used in No
2 min read
Understanding the Prototype Chain in JavaScript
The prototype chain is a core JavaScript concept enabling the inheritance of properties and methods between objects. It facilitates code reuse, efficient property lookup, and object hierarchy creation.Every JavaScript object has an internal link to another object, called its prototype.The prototype
3 min read
What is difference between CoffeeScript and ES6 ?
CoffeeScript is just like JavaScript is a lightweight language that compiles into JavaScript. It provides simple and easy-to-learn syntax avoiding the complex syntax of JavaScript. CoffeeScript is influenced by JavaScript, Ruby, YAML, Haskell, Perl, and Python and has influenced MoonScript, LiveScri
2 min read
How to Link JavaScript File to a Separate HTML File?
Linking a JavaScript file to an HTML document creates a connection that enables the execution of JavaScript code within the webpage. This is commonly achieved using the <script> tag in the HTML file, where the src attribute specifies the path to the external JavaScript file. Approximately 90%
2 min read
TypeScript Exercises, Practice Questions and Solutions
TypeScript Online Practice Question: Explore TypeScript Exercises, an interactive practice set to upscale your TypeScript skills, track progress, and enhance coding skills with our engaging portal. Ideal for beginners and experienced developers, Level up your TypeScript proficiency at your own pace.
3 min read
JavaScript Interview Questions and Answers
JavaScript (JS) is the most popular lightweight, scripting, and interpreted programming language. JavaScript is well-known as a scripting language for web pages, mobile apps, web servers, and many other platforms. Both front-end and back-end developers need to have a strong command of JavaScript, as
15+ min read