new
Operatorsuper
Keyword? :
),
)if
Statementdo
-while
Statementwhile
Statementfor
Statementfor
-in
,for
-of
, andfor
-await
-of
Statementscontinue
Statementbreak
Statementreturn
Statementwith
Statementswitch
Statementthrow
Statementtry
Statementdebugger
Statement?
u
m
/
p
1-9
0
`
An interface is a set of
Theiterable interface includes the property described in
Property | Value | Requirements |
---|---|---|
%Symbol.iterator% | a function that returns an | The returned object must conform to the |
An object that implements theiterator interface must include the property in
Property | Value | Requirements |
---|---|---|
a function that returns an | The returned object must conform to thenext method of annext method of that object should also return an |
Arguments may be passed to thenext
function but their interpretation and validity is dependent upon the target iterator. The for-of statement and other common users of iterators do not pass any arguments, so iterator objects that expect to be used in such a manner must be prepared to deal with being called with no arguments.
Property | Value | Requirements |
---|---|---|
a function that returns an | The returned object must conform to thenext method calls to thereturn method. However, this requirement is not enforced. | |
a function that returns an | The returned object must conform to thethrow the value passed as the argument. If the method does notthrow , the returned |
Typically callers of these methods should check for their existence before invoking them. Certain ECMAScript language features includingfor
-of
,yield*
, and array destructuring call these methods after performing an existence check. Most ECMAScript library functions that accept
Theasync iterable interface includes the properties described in
Property | Value | Requirements |
---|---|---|
%Symbol.asyncIterator% | a function that returns an | The returned object must conform to the |
An object that implements theasync iterator interface must include the properties in
Property | Value | Requirements |
---|---|---|
a function that returns a promise for an | The returned promise, when fulfilled, must fulfill with an object that conforms to the Additionally, the |
Arguments may be passed to thenext
function but their interpretation and validity is dependent upon the target async iterator. Thefor
-await
-of
statement and other common users of async iterators do not pass any arguments, so async iterator objects that expect to be used in such a manner must be prepared to deal with being called with no arguments.
Property | Value | Requirements |
---|---|---|
a function that returns a promise for an | The returned promise, when fulfilled, must fulfill with an object that conforms to the Additionally, the | |
a function that returns a promise for an | The returned promise, when fulfilled, must fulfill with an object that conforms to the If the returned promise is fulfilled, the |
Typically callers of these methods should check for their existence before invoking them. Certain ECMAScript language features includingfor
-await
-of
andyield*
call these methods after performing an existence check.
TheIteratorResult interface includes the properties listed in
Property | Value | Requirements |
---|---|---|
a Boolean | This is the result status of annext method call. If the end of the | |
an | If done is |
AnIterator Helper object is an
The%IteratorHelperPrototype% object:
The initial value of the
This property has the attributes {[[Writable]]:
TheIterator
This function performs the following steps when called:
The%WrapForValidIteratorPrototype% object:
The initial value of Iterator.prototype is the
This property has the attributes {[[Writable]]:
TheIterator prototype object:
All objects defined in this specification that implement the
The following expression is one way that ECMAScript code can access the %Iterator.prototype% object:
Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))
Iterator.prototype.constructor
is an
The value of the[[Get]] attribute is a built-in function that requires no arguments. It performs the following steps when called:
The value of the[[Set]] attribute is a built-in function that takes an argumentv. It performs the following steps when called:
Unlike the
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This function performs the following steps when called:
The value of the
Iterator.prototype[%Symbol.toStringTag%]
is an
The value of the[[Get]] attribute is a built-in function that requires no arguments. It performs the following steps when called:
The value of the[[Set]] attribute is a built-in function that takes an argumentv. It performs the following steps when called:
Unlike the
The%AsyncIteratorPrototype% object:
All objects defined in this specification that implement the
This function performs the following steps when called:
The value of the
AnAsync-from-Sync Iterator object is an
The abstract operation CreateAsyncFromSyncIterator takes argumentsyncIteratorRecord (an
The%AsyncFromSyncIteratorPrototype% object:
throw
method, close it to give it a chance to clean up before we reject the capability.throw
method.Async-from-Sync
Internal Slot | Type | Description |
---|---|---|
[[SyncIteratorRecord]] | an | Represents the original synchronous |
The abstract operation AsyncFromSyncIteratorContinuation takes argumentsresult (an Object),promiseCapability (a
A Promise is an object that is used as a placeholder for the eventual results of a deferred (and possibly asynchronous) computation.
Any Promise is in one of three mutually exclusive states:fulfilled,rejected, andpending:
p
is fulfilled ifp.then(f, r)
will immediately enqueue af
.p
is rejected ifp.then(f, r)
will immediately enqueue ar
.A promise is said to besettled if it is not pending, i.e. if it is either fulfilled or rejected.
A promise isresolved if it is settled or if it has been “locked in” to match the state of another promise. Attempting to resolve or reject a resolved promise has no effect. A promise isunresolved if it is not resolved. An unresolved promise is always in the pending state. A resolved promise may be pending, fulfilled or rejected.
APromiseCapability Record is a
PromiseCapability Records have the fields listed in
Field Name | Value | Meaning |
---|---|---|
[[Promise]] | an Object | An object that is usable as a promise. |
[[Resolve]] | a | The function that is used to resolve the given promise. |
[[Reject]] | a | The function that is used to reject the given promise. |
IfAbruptRejectPromise is a shorthand for a sequence of algorithm steps that use a
means the same thing as:
APromiseReaction Record is a
PromiseReaction Records have the fields listed in
Field Name | Value | Meaning |
---|---|---|
[[Capability]] | a | The capabilities of the promise for which this record provides a reaction handler. |
[[Type]] | The[[Type]] is used when[[Handler]] is | |
[[Handler]] | a | The function that should be applied to the incoming value, and whose return value will govern what happens to the derived promise. If[[Handler]] is |
The abstract operation CreateResolvingFunctions takes argumentpromise (a Promise) and returns a
A promise reject function is an anonymous built-in function that has[[Promise]] and[[AlreadyResolved]] internal slots.
When a promise reject function is called with argumentreason, the following steps are taken:
The
A promise resolve function is an anonymous built-in function that has[[Promise]] and[[AlreadyResolved]] internal slots.
When a promise resolve function is called with argumentresolution, the following steps are taken:
The
The abstract operation FulfillPromise takes argumentspromise (a Promise) andvalue (an
The abstract operation NewPromiseCapability takes argumentC (anresolve
andreject
functions. The promise plus theresolve
andreject
functions are used to initialize a new
This abstract operation supports Promise subclassing, as it is generic on any
The abstract operation IsPromise takes argumentx (an
The abstract operation RejectPromise takes argumentspromise (a Promise) andreason (an
The abstract operation TriggerPromiseReactions takes argumentsreactions (a
The
The default implementation of HostPromiseRejectionTracker is to return
HostPromiseRejectionTracker is called in two scenarios:
A typical implementation of HostPromiseRejectionTracker might try to notify developers of unhandled rejections, while also being careful to notify them if such previous notifications are later invalidated by new handlers being attached.
Ifoperation is
The abstract operation NewPromiseReactionJob takes argumentsreaction (a
The abstract operation NewPromiseResolveThenableJob takes argumentspromiseToResolve (a Promise),thenable (an Object), andthen (a
The Promise
extends
clause of a class definition. Subclasssuper
call to the PromisePromise
andPromise.prototype
built-in methods.This function performs the following steps when called:
Theexecutor argument must be a
Theresolve function that is passed to anexecutor function accepts a single argument. Theexecutor code may eventually call theresolve function to indicate that it wishes to resolve the associated Promise. The argument passed to theresolve function represents the eventual value of the deferred action and can be either the actual fulfillment value or another promise which will provide the value if it is fulfilled.
Thereject function that is passed to anexecutor function accepts a single argument. Theexecutor code may eventually call thereject function to indicate that the associated Promise is rejected and will never be fulfilled. The argument passed to thereject function is used as the rejection value of the promise. Typically it will be an Error object.
The resolve and reject functions passed to anexecutor function by the Promise
The Promise
This function returns a new promise which is fulfilled with an array of fulfillment values for the passed promises, or rejects with the reason of the first passed promise that rejects. It resolves all elements of the passed
This function requires its
The abstract operation GetPromiseResolve takes argumentpromiseConstructor (a
The abstract operation PerformPromiseAll takes argumentsiteratorRecord (an
Promise.all
Resolve Element FunctionsPromise.all
Resolve Element FunctionsPromise.all
Resolve Element FunctionsAPromise.all
resolve element function is an anonymous built-in function that is used to resolve a specificPromise.all
element. EachPromise.all
resolve element function has[[Index]],[[Values]],[[Capability]],[[RemainingElements]], and[[AlreadyCalled]] internal slots.
When aPromise.all
resolve element function is called with argumentx, the following steps are taken:
ThePromise.all
resolve element function is
This function returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected. It resolves all elements of the passed
This function requires its
The abstract operation PerformPromiseAllSettled takes argumentsiteratorRecord (an
Promise.allSettled
Resolve Element FunctionsPromise.allSettled
Resolve Element FunctionsPromise.allSettled
Reject Element FunctionsPromise.allSettled
Reject Element FunctionsPromise.allSettled
Resolve Element FunctionsAPromise.allSettled
resolve element function is an anonymous built-in function that is used to resolve a specificPromise.allSettled
element. EachPromise.allSettled
resolve element function has[[Index]],[[Values]],[[Capability]],[[RemainingElements]], and[[AlreadyCalled]] internal slots.
When aPromise.allSettled
resolve element function is called with argumentx, the following steps are taken:
ThePromise.allSettled
resolve element function is
Promise.allSettled
Reject Element FunctionsAPromise.allSettled
reject element function is an anonymous built-in function that is used to reject a specificPromise.allSettled
element. EachPromise.allSettled
reject element function has[[Index]],[[Values]],[[Capability]],[[RemainingElements]], and[[AlreadyCalled]] internal slots.
When aPromise.allSettled
reject element function is called with argumentx, the following steps are taken:
ThePromise.allSettled
reject element function is
This function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with anAggregateError
holding the rejection reasons if all of the given promises are rejected. It resolves all elements of the passed
This function requires itsPromise
The abstract operation PerformPromiseAny takes argumentsiteratorRecord (an
Promise.any
Reject Element FunctionsPromise.any
Reject Element FunctionsPromise.any
Reject Element FunctionsAPromise.any
reject element function is an anonymous built-in function that is used to reject a specificPromise.any
element. EachPromise.any
reject element function has[[Index]],[[Errors]],[[Capability]],[[RemainingElements]], and[[AlreadyCalled]] internal slots.
When aPromise.any
reject element function is called with argumentx, the following steps are taken:
ThePromise.any
reject element function is
The initial value ofPromise.prototype
is the
This property has the attributes {[[Writable]]:
This function returns a new promise which is settled in the same way as the first passed promise to settle. It resolves all elements of the passediterable to promises as it runs this algorithm.
If theiterable argument yields no values or if none of the promises yielded byiterable ever settle, then the pending promise returned by this method will never be settled.
This function expects itsresolve
method.
The abstract operation PerformPromiseRace takes argumentsiteratorRecord (an
This function returns a new promise rejected with the passed argument.
This function expects its
This function returns either a new promise resolved with the passed argument, or the argument itself if the argument is a promise produced by this
This function expects its
The abstract operation PromiseResolve takes argumentsC (an Object) andx (an
This function performs the following steps when called:
This function expects its
This function returns an object with three properties: a new promise together with theresolve
andreject
functions associated with it.
Promise[%Symbol.species%]
is an
The value of the
Promise prototype methods normally use their
ThePromise prototype object:
This method performs the following steps when called:
The initial value ofPromise.prototype.constructor
is
This method performs the following steps when called:
This method performs the following steps when called:
The abstract operation PerformPromiseThen takes argumentspromise (a Promise),onFulfilled (an
The initial value of the
This property has the attributes {[[Writable]]:
Promise instances are
Internal Slot | Type | Description |
---|---|---|
[[PromiseState]] | Governs how a promise will react to incoming calls to itsthen method. | |
[[PromiseResult]] | an | The value with which the promise has been fulfilled or rejected, if any. |
[[PromiseFulfillReactions]] | a | |
[[PromiseRejectReactions]] | a | |
[[PromiseIsHandled]] | a Boolean | Indicates whether the promise has ever had a fulfillment or rejection handler; used in unhandled rejection tracking. |
GeneratorFunctions are functions that are usually created by evaluating
The GeneratorFunction
Function
.GeneratorFunction (…)
is equivalent to the object creation expressionnew GeneratorFunction (…)
with the same arguments.extends
clause of a class definition. Subclasssuper
call to the GeneratorFunctionThe last argument (if any) specifies the body (executable code) of a generator function; any preceding arguments specify formal parameters.
This function performs the following steps when called:
See NOTE for
The GeneratorFunction
The initial value ofGeneratorFunction.prototype
is the
This property has the attributes {[[Writable]]:
TheGeneratorFunction prototype object:
The initial value ofGeneratorFunction.prototype.constructor
is
This property has the attributes {[[Writable]]:
The initial value ofGeneratorFunction.prototype.prototype
is
This property has the attributes {[[Writable]]:
The initial value of the
This property has the attributes {[[Writable]]:
Every GeneratorFunction instance is an ECMAScript
Each GeneratorFunction instance has the following own properties:
The specification for the
The specification for the
Whenever a GeneratorFunction instance is created another
This property has the attributes {[[Writable]]:
Unlike Function instances, the object that is the value of a GeneratorFunction's
AsyncGeneratorFunctions are functions that are usually created by evaluating
The AsyncGeneratorFunction
Function
.AsyncGeneratorFunction (...)
is equivalent to the object creation expressionnew AsyncGeneratorFunction (...)
with the same arguments.extends
clause of a class definition. Subclasssuper
call to the AsyncGeneratorFunctionThe last argument (if any) specifies the body (executable code) of an async generator function; any preceding arguments specify formal parameters.
This function performs the following steps when called:
See NOTE for
The AsyncGeneratorFunction
The initial value ofAsyncGeneratorFunction.prototype
is the
This property has the attributes {[[Writable]]:
TheAsyncGeneratorFunction prototype object:
The initial value ofAsyncGeneratorFunction.prototype.constructor
is
This property has the attributes {[[Writable]]:
The initial value ofAsyncGeneratorFunction.prototype.prototype
is
This property has the attributes {[[Writable]]:
The initial value of the
This property has the attributes {[[Writable]]:
Every AsyncGeneratorFunction instance is an ECMAScript
Each AsyncGeneratorFunction instance has the following own properties:
The value of the
This property has the attributes {[[Writable]]:
The specification for the
Whenever an AsyncGeneratorFunction instance is created, another
This property has the attributes {[[Writable]]:
Unlike function instances, the object that is the value of an AsyncGeneratorFunction's
A Generator is created by calling a generator function and conforms to both the
Generator instances directly inherit properties from the initial value of the
The%GeneratorPrototype% object:
The initial value of.constructor
is
This property has the attributes {[[Writable]]:
This method performs the following steps when called:
This method performs the following steps when called:
The initial value of the
This property has the attributes {[[Writable]]:
Generator instances are initially created with the internal slots described in
Internal Slot | Type | Description |
---|---|---|
[[GeneratorState]] | The current execution state of the generator. | |
[[GeneratorContext]] | an | The |
[[GeneratorBrand]] | a String or | A brand used to distinguish different kinds of generators. The[[GeneratorBrand]] of generators declared by |
The abstract operation GeneratorStart takes argumentsgenerator (a Generator) andgeneratorBody (a
The abstract operation GeneratorValidate takes argumentsgenerator (an
The abstract operation GeneratorResume takes argumentsgenerator (an
The abstract operation GeneratorResumeAbrupt takes argumentsgenerator (an
The abstract operation GetGeneratorKind takes no arguments and returns
The abstract operation GeneratorYield takes argumentiteratorResult (an Object that conforms to the
The abstract operation Yield takes argumentvalue (an
The abstract operation CreateIteratorFromClosure takes argumentsclosure (an
An AsyncGenerator is created by calling an async generator function and conforms to both the
AsyncGenerator instances directly inherit properties from the initial value of the
The%AsyncGeneratorPrototype% object:
The initial value of.constructor
is
This property has the attributes {[[Writable]]:
The initial value of the
This property has the attributes {[[Writable]]:
AsyncGenerator instances are initially created with the internal slots described below:
Internal Slot | Type | Description |
---|---|---|
[[AsyncGeneratorState]] | The current execution state of the async generator. | |
[[AsyncGeneratorContext]] | an | The |
[[AsyncGeneratorQueue]] | a | |
[[GeneratorBrand]] | a String or | A brand used to distinguish different kinds of async generators. The[[GeneratorBrand]] of async generators declared by |
AnAsyncGeneratorRequest is a
They have the following fields:
Field Name | Value | Meaning |
---|---|---|
[[Completion]] | a | The |
[[Capability]] | a | The promise capabilities associated with this request. |
The abstract operation AsyncGeneratorStart takes argumentsgenerator (an AsyncGenerator) andgeneratorBody (a
The abstract operation AsyncGeneratorValidate takes argumentsgenerator (an
The abstract operation AsyncGeneratorEnqueue takes argumentsgenerator (an AsyncGenerator),completion (a
The abstract operation AsyncGeneratorCompleteStep takes argumentsgenerator (an AsyncGenerator),completion (a
The abstract operation AsyncGeneratorResume takes argumentsgenerator (an AsyncGenerator) andcompletion (a
The abstract operation AsyncGeneratorUnwrapYieldResumption takes argumentresumptionValue (a
The abstract operation AsyncGeneratorYield takes argumentvalue (an
The abstract operation AsyncGeneratorAwaitReturn takes argumentgenerator (an AsyncGenerator) and returns
The abstract operation AsyncGeneratorDrainQueue takes argumentgenerator (an AsyncGenerator) and returns
The abstract operation CreateAsyncIteratorFromClosure takes argumentsclosure (an
AsyncFunctions are functions that are usually created by evaluating
The AsyncFunction
Function
.AsyncFunction(…)
is equivalent to the object creation expressionnew AsyncFunction(…)
with the same arguments.extends
clause of a class definition. Subclasssuper
call to the AsyncFunctionThe last argument (if any) specifies the body (executable code) of an async function. Any preceding arguments specify formal parameters.
This function performs the following steps when called:
The AsyncFunction
The initial value ofAsyncFunction.prototype
is the
This property has the attributes {[[Writable]]:
TheAsyncFunction prototype object:
The initial value ofAsyncFunction.prototype.constructor
is
This property has the attributes {[[Writable]]:
The initial value of the
This property has the attributes {[[Writable]]:
Every AsyncFunction instance is an ECMAScript
Each AsyncFunction instance has the following own properties:
The specification for the
The specification for the
The abstract operation AsyncFunctionStart takes argumentspromiseCapability (a
The abstract operation AsyncBlockStart takes argumentspromiseCapability (a
The abstract operation Await takes argumentvalue (an