Statements and declarations

31 features: 3 implemented, 22 partial, 5 planned, 1 excluded. Back to all areas.

FeatureStatusWhat worksTest
async functionimplementedAn async function declaration returns a promise the body settles: a return fulfils it, a throw or an abrupt parameter initializer rejects it. Async methods of classes and object literals are taken too.
async function*partialAn async generator is a generator body whose next, return and throw go through the async generator driver: await suspends it as in an async function, and yield hands the driver a value to await before it settles the request. Async generator methods of classes and object literals are taken too. yield* in an async generator hands its operand to the driver, which runs the requests on its iterator until it is done.
await usingplannedOutside the first executable profile.
blockpartialAvailable for supported scalar expressions and statements.
breakpartialAvailable for supported scalar expressions and statements.
classplannedOutside the first executable profile.
constpartialIdentifier declaration lists initialize left to right. A closure may capture a subsequent declarator and reading it prematurely raises ReferenceError. Global lexicals are visible across scripts in the same realm. Destructuring remains open. See tests/declaration-lists.js.
continuepartialAvailable for supported scalar expressions and statements.
debuggerimplementedWithout an attached debugger the statement completes normally. The compiler emits no instruction or host effect.tests/debugger.js
do...whilepartialPost-tested loops execute their body once before checking the condition. Break and continue target the enclosing loop.tests/control.js
EmptyimplementedA semicolon in statement position completes normally, including as the body of an if.tests/control.js
exportpartialNamed function exports are callable by the embedder. Named variable exports are live bindings for linked source modules. Namespace objects and re-exports remain in scope.
Expression statementpartialStandalone calls run in module and function bodies. Their effects are observable and their values are discarded. Expression forms such as comma and dynamic import remain open.tests/module-effects/consumer.js
forpartialClassic loops accept let, const and var declaration lists and comma-separated updates. Captured let bindings have distinct cells in the initializer and each iteration. See tests/declaration-lists.js.tests/declaration-lists.js
for-await...ofpartialfor await in an async function or an async generator takes its iterator from @@asyncIterator, or else from @@iterator with each value awaited as the async-from-sync iterator does, and awaits each next result; break, return and throw close it with an awaited return. At the top level of a module it is not built yet.
for...inplannedOutside the first executable profile.
for...ofpartialLoop over arrays, string code points, Maps, Sets and their built-in iterators, including a dynamically typed source. Array length is read on each advance. Statically known arrays and strings use frame-local indices. A break leaves a built-in iterator positioned for its next call. User-defined iteration and closing remain in scope.tests/iterators.ts
functionpartialAvailable for supported scalar expressions and statements.
function*partialAn exported numeric generator can suspend, resume and unwind through its handlers using the host API. Guest generator objects remain open.
if...elsepartialBraced and single-statement branches use truth conversion. Each else binds to the nearest unmatched if. Sloppy-mode function declaration branches remain open.tests/control.js
importpartialRelative named imports resolve functions and read-only aliases of exported module variables. Module-wide const, let and var evaluate initializer expressions, including calls, closures and host effects. Cyclic dependencies observe hoisted var and lexical temporal dead zones. Values persist independently per realm. Side-effect imports, including empty named lists, evaluate each reachable module once. Top-level expression statements and throw execute between declarations in source order. With a top-level await every module's steps run in one async body, so a module waiting at an await also holds back the evaluation of its siblings, which ECMA-262 evaluates meanwhile.
labelplannedOutside the first executable profile.
letpartialAn unannotated local keeps its specialized lane while its uses agree. If a later assignment or numeric update requires another representation, the compiler re-emits the function with that binding tagged. Captured mutable bindings retain their shared identity.
returnpartialAvailable for supported scalar expressions and statements.
switchpartialEvaluate the discriminant once, then test selectors in source order with strict equality. Dense signed integer selectors lower to a WASM br_table. Clauses share one lexical scope and fall through. Unlabelled break and enclosing-loop continue cross finally blocks.tests/switch.js
throwpartialOrdinary functions throw arbitrary guest values through direct and indirect calls using a standard WebAssembly exception tag. Uncaught values reach the embedder by identity. Generator bodies support numeric throws.
try...catchpartialOrdinary try/catch preserves object identity and supports optional, mutable and captured catch bindings. The loader prepares handler ranges once. Tag matching and stack unwinding run only when an exception is raised. Ordinary and generator functions support nested try/finally and try/catch/finally. A finalizer runs for normal completion, return, throw, break and continue. Its own abrupt completion replaces the pending one. Ordinary returns keep their native WASM representation while cleanup runs, including across host requests. Catchable built-in errors remain in progress.tests/exceptions.ts
usingplannedOutside the first executable profile.
varpartialSimple function-scoped names are initialized to undefined at entry. Initializers execute in source order. Repeated declarations share a binding with parameters and function declarations. Classic and for-of loops keep one shared variable across iterations. Module var initializes once per realm. Script var and function declarations install shared global properties when that script is called. A repeated var declaration preserves the prior value. Global lexical declarations use a separate realm environment. Destructuring remains in scope.
whilepartialAvailable for supported scalar expressions and statements.
withexcludedSource modules are strict. Dynamic scope injection conflicts with statically resolved bindings.
At tinyscript commit 0c5984ec; each test is a program that runs the feature.