10.3 Built-in Function Objects
A built-in
In addition to the internal slots required of every
- [[Realm]], a
Realm Record that represents therealm in which the function was created. - [[InitialName]], a String that is the initial name of the function. It is used by
20.2.3.5 .
The initial value of a built-in
A built-in
A built-in
An implementation may provide additional built-in
10.3.1 [[Call]] ( thisArgument, argumentsList )
The [[Call]] internal method of a built-in
- Return ?
BuiltinCallOrConstruct (F, thisArgument, argumentsList,undefined ).
10.3.2 [[Construct]] ( argumentsList, newTarget )
The [[Construct]] internal method of a built-in
- Return ?
BuiltinCallOrConstruct (F,uninitialized , argumentsList, newTarget).
10.3.3 BuiltinCallOrConstruct ( F, thisArgument, argumentsList, newTarget )
The abstract operation BuiltinCallOrConstruct takes arguments F (a built-in
- Let callerContext be the
running execution context . - If callerContext is not already suspended, suspend callerContext.
- Let calleeContext be a new
execution context . - Set the Function of calleeContext to F.
- Let calleeRealm be F.[[Realm]].
- Set the
Realm of calleeContext to calleeRealm. - Set the ScriptOrModule of calleeContext to
null . - Perform any necessary
implementation-defined initialization of calleeContext. - Push calleeContext onto the
execution context stack ; calleeContext is now therunning execution context . - Let result be the
Completion Record that is the result of evaluating F in a manner that conforms to the specification of F. If thisArgument isuninitialized , thethis value is uninitialized; otherwise, thisArgument provides thethis value. argumentsList provides the named parameters. newTarget provides the NewTarget value. - NOTE: If F is defined in this document, “the specification of F” is the behaviour specified for it via algorithm steps or other means.
- Remove calleeContext from the
execution context stack and restore callerContext as therunning execution context . - Return ? result.
When calleeContext is removed from the
10.3.4 CreateBuiltinFunction ( behaviour, length, name, additionalInternalSlotsList [ , realm [ , prototype [ , prefix ] ] ] )
The abstract operation CreateBuiltinFunction takes arguments behaviour (an
- If realm is not present, set realm to
the current Realm Record . - If prototype is not present, set prototype to realm.[[Intrinsics]].[[
%Function.prototype% ]]. - Let internalSlotsList be a
List containing the names of all the internal slots that10.3 requires for the built-infunction object that is about to be created. - Append to internalSlotsList the elements of additionalInternalSlotsList.
- Let func be a new built-in
function object that, when called, performs the action described by behaviour using the provided arguments as the values of the corresponding parameters specified by behaviour. The newfunction object has internal slots whose names are the elements of internalSlotsList, and an [[InitialName]] internal slot. - Set func.[[Prototype]] to prototype.
- Set func.[[Extensible]] to
true . - Set func.[[Realm]] to realm.
- Set func.[[InitialName]] to
null . - Perform
SetFunctionLength (func, length). - If prefix is not present, then
- Perform
SetFunctionName (func, name).
- Perform
- Else,
- Perform
SetFunctionName (func, name, prefix).
- Perform
- Return func.
Each built-in function defined in this specification is created by calling the CreateBuiltinFunction abstract operation.