Aller au contenu

Cette page n'est pas encore traduite. Elle s'affiche en anglais.

JavaScript language

Which ECMAScript edition and proposals Elide runs (Temporal, ShadowRealm, AsyncContext, using, Float16Array), and the non-standard globals print, printErr, gc, Operators, Process and XMLHttpRequest.

Sur cette page

Elide runs ECMAScript 2025 and the newer features below, with no flag. The project’s javascript.ecma setting is informational and does not change them.

Language features

FeatureStatus
ECMAScript 2025: iterator helpers, Set methods, Promise.try, RegExp.escape, import attributes, regexp modifiers, duplicate named groupsSupported
using, await using, DisposableStack, AsyncDisposableStackSupported
Float16Array, Math.f16roundSupported
TemporalSupported
ShadowRealmSupported
AsyncContext.Variable, AsyncContext.SnapshotSupported; values follow await, .then(), timers, setImmediate, process.nextTick and queueMicrotask
Error.isError, Math.sumPrecise, Iterator.concat, Map.prototype.getOrInsertSupported
Uint8Array.fromBase64, toBase64, fromHex, toHexSupported
JSON.parse source text access (context.source in the reviver)Supported
DecoratorsStandard decorators; see TypeScript and modules
IntlSupported
// modern.mjs
{
  using file = { [Symbol.dispose]() { console.log("closed"); } };
  console.log("open");
}

const due = Temporal.PlainDate.from("2026-10-11").add({ days: 30 });
console.log(due.toString(), due.dayOfWeek);

const request = new AsyncContext.Variable();
await request.run("req-1", async () => {
  await null;
  console.log("request", request.get());
});

const realm = new ShadowRealm();
console.log(realm.evaluate("typeof process"));

console.log(new Float16Array([1.337])[0]);
console.log([1, 2, 3].values().map((x) => x * 2).toArray().join());
elide modern.mjs
open
closed
2026-11-10 2
request req-1
undefined
1.3369140625
2,4,6

A ShadowRealm has the ECMAScript built-ins, console and require, but no process, fetch or Buffer.

Non-standard globals

GlobalBehavior
print(...values)Writes the values to stdout, separated by spaces. Objects print as [object Object].
printErr(...values)The same, to stderr.
gc()Defined only when the program receives --expose-gc: elide app.mjs -- --expose-gc. Requests a garbage collection.
Operators(table)Operator overloading: returns a base class whose subclasses use the functions in table for +, -, < and the other operators.
ProcessThe class of process; new Process() throws TypeError: Creating Process instances is not allowed.
XMLHttpRequestNot supported. The constructor exists, but every request fails: onerror fires and status is 0. Use fetch.
const Vector = Operators({ "+"(a, b) { return new Vec(a.x + b.x); } });
class Vec extends Vector {
  constructor(x) { super(); this.x = x; }
}
console.log((new Vec(1) + new Vec(2)).x); // 3

Samples

See also

Cette page vous a-t-elle aidé ?