Fundamentals 13 min read

What New ECMAScript Features Are Advancing to Stage 4 in 2023?

The article reviews recent TC39 decisions, detailing how proposals such as Hashbang Grammar, Duplicate Named Capturing Groups, Import Reflection, Function Memoization, Policy Maps and Sets, Symbol Predicates, and Object.pick/omit progressed through the ECMAScript staging process and what criteria each stage requires.

Alibaba Terminal Technology
Alibaba Terminal Technology
Alibaba Terminal Technology
What New ECMAScript Features Are Advancing to Stage 4 in 2023?

At the latest TC39 meeting, the Hashbang Grammar proposal reached Stage 4 and will become an official ECMAScript 2023 feature. Earlier Stage 2 proposals like Duplicate Named Capturing Groups and Import Reflection also moved forward, while Function Memoization, Object.pick/omit and other ideas entered Stage 1.

Stage 3 → Stage 4

Advancing from Stage 3 to Stage 4 requires:

Complete test262 tests for the proposal.

At least two implementations passing those tests and shipping in a release.

A pull request merging the proposal into the ECMA‑262 spec, approved by the ECMAScript editor.

Hashbang Grammar

Proposal: proposal‑hashbang

Hashbang (shebang) syntax (e.g., #!/usr/bin/env node) lets a script declare its interpreter. The proposal makes the shebang part of the source code visible to the engine instead of being stripped.

#!/usr/bin/env node
console.log("ecma");

Running with Node:

$ node index.js

With a shebang and executable permission, the script can be run directly:

$ ./index.js
/usr/bin/env

locates the interpreter (e.g., node) on the system, avoiding hard‑coded paths.

Stage 2 → Stage 3

Advancing from Stage 2 to Stage 3 requires:

A draft spec text reviewed and signed by a TC39 member.

Signature from the ECMAScript editor.

Duplicate Named Capturing Groups

Proposal: proposal‑duplicate‑named‑capturing‑groups

Current named capture groups must have unique names, preventing their use in alternations such as

(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})|(?<day>\d{2})-(?<month>\d{2})-(?<year>\d{4})

. The proposal allows non‑unique names to enable such patterns.

Stage 1 → Stage 2

Moving to Stage 2 requires a draft spec covering the entire proposal.

Import Reflection

Proposal: proposal‑import‑reflection

Extends import with a reflection type, e.g.:

import module x from "<specifier>";
const x = await import("<specifier>", { reflect: "module" });

Used to annotate WebAssembly imports, allowing the engine to treat them as WebAssembly.Module or WebAssembly.Instance objects.

import module FooModule from "./foo.wasm";
FooModule instanceof WebAssembly.Module; // true

Stage 0 → Stage 1

Requirements for Stage 0 to Stage 1:

Find a TC39 champion.

Define the problem, need, and a rough solution.

Provide examples.

Discuss API shape, algorithms, semantics, and implementation risks.

Symbol Predicates

Proposal: proposal‑symbol‑predicates

Introduces Symbol.isRegistered and Symbol.isWellKnown to test whether a Symbol is globally registered or a built‑in well‑known Symbol.

Policy Maps and Sets

Proposal: proposal‑policy‑map‑set

Adds native cache‑policy data structures (FIFO, LIFO, LRU, LFU) as built‑in Map/Set‑like objects:

new FIFOMap(maxEntries, entries = []);
new LRUSet(maxValues, values = []);
// etc.

Function Memoization

Proposal: proposal‑function‑memo

Provides Function.prototype.memo to return a memoized version of a function:

function f(x) { console.log(x); return x * 2; }
const fMemo = f.memo();

Also adds the @Function.memo decorator for concise syntax.

@Function.memo
function f(x) { console.log(x); return x * 2; }

Allows custom cache objects implementing .get(), .has(), .set() to control memoization.

Object pick/omit

Proposal: proposal‑object‑pick‑or‑omit

Introduces Object.pick(obj, keysOrPredicate) and Object.omit(obj, keysOrPredicate) to extract or remove properties, similar to Lodash’s pick / omit but with native support for dynamic keys and prototype properties.

Object.pick(obj, ['job', 'sex']);
Object.omit(obj, ['name', 'age']);
Object.pick({a:1,b:2}, v => v===1); // => {a:1}

Conclusion

The JavaScript Chinese Interest Group (JSCIG) invites developers to discuss these and other ECMAScript proposals on GitHub: https://github.com/JSCIG/es-discuss/discussions .

ECMAScriptTC39Language Proposalsfunction memoizationhashbangobject pick omit
Alibaba Terminal Technology
Written by

Alibaba Terminal Technology

Official public account of Alibaba Terminal

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.