JS Tip of the Day: ECMAScript New Feature Proposals

ECMAScript New Feature Proposals

JavaScript, as a language, is constantly evolving. Every year a new version of the language specification (ECMAScript) gets released along with any of the new features which may have been added to it. Until that time, new features exist as proposals which need to get approved by a technical committee (TC39) before they become fully standardized.

There are 5 stages to a proposal:

  • Stage 0: An idea for a new language feature exists. It may not necessarily be tracked by the technical committee yet.
  • Stage 1: An idea has more detail and a “champion” that will help it advance through the remaining steps. The committe will look into potential problems and concerns.
  • Stage 2: Specifics for an idea should be flushed out and available in the formal spec language. At this stage, its highly likely, but not guaranteed, that the feature will eventually make it into the final spec.
  • Stage 3: Details of the idea have been ironed out and the feature is ready for inclusion into the spec. Features in this stage are highly likely to be included in the spec and will even start appearing within language implementations (e.g. browsers).
  • Stage 4: The feature is complete and the committee has approved it for inclusion in the next version of the spec.

Once a feature reaches stage 4, it’s officially part of the standard you should start seeing support for the feature in browsers and other runtimes. But you may also see some proposals available in browsers before then. Private fields in classes, for example, is a stage 3 proposal but is currently supported by Chrome.

// not officially standard but
// works today in Chrome
class Stern {
    #parts = 2 // private field

    getParts () {
        return this.#parts; // ok
    }
}

let howard = new Stern();
console.log(howard.getParts()); // 2
console.log(howard.#parts); // SyntaxError

Class fields are not officially standardized, and even though you can use them in Chrome today, you probably shouldn’t, at least not with production code. Even when (if?) they are eventually standardized, you may want to wait a while until your users have updated to browsers that support them. Until then, you can use tools like TypeScript which can help by translating your code into more compatible that can run in older browsers, even if you’re writing it using newer features (TypeScript supports many stage 3 features). Support for private class fields were added in TypeScript 2.8.

More info: