All ordinary objects have an internal slot called [[Prototype]]. The value of this internal slot is either null or an object and is used for implementing inheritance. Data properties of the [[Prototype]] object are inherited (are visible as properties of the child object) for the purposes of get access, but not for set access. Accessor properties are inherited for both get access and set access.
Every ordinary object has a Boolean-valued [[Extensible]] internal slot that controls whether or not properties may be added to the object. If the value of the [[Extensible]] internal slot is false then additional properties may not be added to the object. In addition, if [[Extensible]] is false the value of the [[Prototype]] internal slot of the object may not be modified. Once the value of an object's [[Extensible]] internal slot has been set to false it may not be subsequently changed to true.
In the following algorithm descriptions, assume O is an ordinary object, P is a property key value, V is any ECMAScript language value, and Desc is a Property Descriptor record.
When the [[GetPrototypeOf]] internal method of O is called the following steps are taken:
When the [[SetPrototypeOf]] internal method of O is called with argument V the following steps are taken:
NOTE The loop in step 8 guarantees that there will be no circularities in any prototype chain that only includes objects that use the ordinary object definitions for [[GetPrototypeOf]] and [[SetPrototypeOf]].
When the [[IsExtensible]] internal method of O is called the following steps are taken:
When the [[PreventExtensions]] internal method of O is called the following steps are taken:
When the [[GetOwnProperty]] internal method of O is called with property key P, the following steps are taken:
When the abstract operation OrdinaryGetOwnProperty is called with Object O and with property key P, the following steps are taken:
When the [[DefineOwnProperty]] internal method of O is called with property key P and Property Descriptor Desc, the following steps are taken:
When the abstract operation OrdinaryDefineOwnProperty is called with Object O, property key P, and Property Descriptor Desc the following steps are taken:
When the abstract operation IsCompatiblePropertyDescriptor is called with Boolean value Extensible, and Property Descriptors Desc, and Current the following steps are taken:
When the abstract operation ValidateAndApplyPropertyDescriptor is called with Object O, property key P, Boolean value extensible, and Property Descriptors Desc, and current the following steps are taken:
This algorithm contains steps that test various fields of the Property Descriptor Desc for specific values. The fields that are tested in this manner need not actually exist in Desc. If a field is absent then its value is considered to be false.
NOTE 1 If undefined is passed as the O argument only validation is performed and no object updates are performed.
NOTE 2 Step 8.b allows any field of Desc to be different from the corresponding field of current if current’s [[Configurable]] field is true. This even permits changing the [[Value]] of a property whose [[Writable]] attribute is false. This is allowed because a true [[Configurable]] attribute would permit an equivalent sequence of calls where [[Writable]] is first set to true, a new [[Value]] is set, and then [[Writable]] is set to false.
When the [[HasProperty]] internal method of O is called with property key P, the following steps are taken:
When the abstract operation OrdinaryHasProperty is called with Object O and with property key P, the following steps are taken:
When the [[Get]] internal method of O is called with property key P and ECMAScript language value Receiver the following steps are taken:
When the [[Set]] internal method of O is called with property key P, value V, and ECMAScript language value Receiver, the following steps are taken:
When the [[Delete]] internal method of O is called with property key P the following steps are taken:
When the [[Enumerate]] internal method of O is called the following steps are taken:
next
method iterates
over all the String-valued keys of enumerable properties of O. The Iterator object must inherit from
%IteratorPrototype% (25.1.2). The mechanics and order of enumerating the
properties is not specified but must conform to the rules specified below.The iterator's next
method processes object properties to determine whether the property key should be returned as an iterator value. Returned property keys do not include keys
that are Symbols. Properties of the target object may be deleted during enumeration. A property that is deleted before it is
processed by the iterator's next
method is ignored. If new properties are added to the target object
during enumeration, the newly added properties are not guaranteed to be processed in the active enumeration. A property name
will be returned by the iterator's next
method at most once in any enumeration.
Enumerating the properties of the target object includes enumerating properties of its prototype, and the prototype of
the prototype, and so on, recursively; but a property of a prototype is not processed if it has the same name as a property
that has already been processed by the iterator's next
method. The values of [[Enumerable]] attributes
are not considered when determining if a property of a prototype object has already been processed. The enumerable property
names of prototype objects must be obtained as if by invoking the prototype object's [[Enumerate]] internal method.
[[Enumerate]] must obtain the own property keys of the target object as if by calling its [[OwnPropertyKeys]] internal
method. Property attributes of the target object must be obtained as if by calling its [[GetOwnProperty]] internal
method.
NOTE The following is an informative definition of an ECMAScript generator function that conforms to these rules:
function* enumerate(obj) {
let visited=new Set;
for (let key of Reflect.ownKeys(obj)) {
if (typeof key === "string") {
let desc = Reflect.getOwnPropertyDescriptor(obj,key);
if (desc) {
visited.add(key);
if (desc.enumerable) yield key;
}
}
}
let proto = Reflect.getPrototypeOf(obj)
if (proto === null) return;
for (let protoName of Reflect.enumerate(proto)) {
if (!visited.has(protoName)) yield protoName;
}
}
When the [[OwnPropertyKeys]] internal method of O is called the following steps are taken:
The abstract operation ObjectCreate with argument proto (an object or null) is used to specify the runtime creation of new ordinary objects. The optional argument internalSlotsList is a List of the names of additional internal slots that must be defined as part of the object. If the list is not provided, an empty List is used. This abstract operation performs the following steps:
The abstract operation OrdinaryCreateFromConstructor creates an ordinary object whose [[Prototype]]
value is retrieved from a constructor's prototype
property, if it exists. Otherwise the intrinsic named
by intrinsicDefaultProto is used for [[Prototype]]. The optional internalSlotsList is a List of the names of additional internal slots that must be defined as
part of the object. If the list is not provided, an empty List is
used. This abstract operation performs the following steps:
The abstract operation GetPrototypeFromConstructor determines the [[Prototype]] value that should be
used to create an object corresponding to a specific constructor. The value is retrieved from the constructor’s
prototype
property, if it exists. Otherwise the intrinsic named by intrinsicDefaultProto is used for
[[Prototype]]. This abstract operation performs the following steps:
"prototype"
).NOTE If constructor does not supply a [[Prototype]] value, the default value that is used is obtained from the Code Realm of the constructor function rather than from the running execution context.
ECMAScript function objects encapsulate parameterized ECMAScript code closed over a lexical environment and support the dynamic evaluation of that code. An ECMAScript function object is an ordinary object and has the same internal slots and the same internal methods as other ordinary objects. The code of an ECMAScript function object may be either strict mode code (10.2.1) or non-strict mode code. An ECMAScript function object whose code is strict mode code is called a strict function. One whose code is not strict mode code is called a non-strict function.
ECMAScript function objects have the additional internal slots listed in Table 27.
Internal Slot | Type | Description |
---|---|---|
[[Environment]] | Lexical Environment | The Lexical Environment that the function was closed over. Used as the outer environment when evaluating the code of the function. |
[[FormalParameters]] | Parse Node | The root parse node of the source text that defines the function's formal parameter list. |
[[FunctionKind]] | String | Either "normal" , "classConstructor" or "generator" . |
[[ECMAScriptCode]] | Parse Node | The root parse node of the source text that defines the function's body. |
[[ConstructorKind]] | String | Either "base" or "derived" . |
[[Realm]] | Realm Record | The Code Realm in which the function was created and which provides any intrinsic objects that are accessed when evaluating the function. |
[[ThisMode]] | (lexical, strict, global) | Defines how this references are interpreted within the formal parameters and code body of the function. lexical means that this refers to the this value of a lexically enclosing function. strict means that the this value is used exactly as provided by an invocation of the function. global means that a this value of undefined is interpreted as a reference to the global object. |
[[Strict]] | Boolean | true if this is a strict mode function, false if this is not a strict mode function. |
[[HomeObject]] | Object | If the function uses super , this is the object whose [[GetPrototypeOf]] provides the object where super property lookups begin. |
All ECMAScript function objects have the [[Call]] internal method defined here. ECMAScript functions that are also constructors in addition have the [[Construct]] internal method. ECMAScript function objects whose code is not strict mode code have the [[GetOwnProperty]] internal method defined here.
The [[Call]] internal method for an ECMAScript function object F is called with parameters thisArgument and argumentsList, a List of ECMAScript language values. The following steps are taken:
"classConstructor"
, throw a TypeError exception.NOTE When calleeContext is removed from the execution context stack in step 8 it must not be destroyed if it is suspended and retained for later resumption by an accessible generator object.
When the abstract operation PrepareForOrdinaryCall is called with function object F and ECMAScript language value newTarget, the following steps are taken:
When the abstract operation OrdinaryCallBindThis is called with function object F, execution context calleeContext, and ECMAScript value thisArgument the following steps are taken:
"uninitialized"
.When the abstract operation OrdinaryCallEvaluateBody is called with function object F and List argumentsList the following steps are taken:
The [[Construct]] internal method for an ECMAScript Function object F is called with parameters argumentsList and newTarget. argumentsList is a possibly empty List of ECMAScript language values. The following steps are taken:
"base"
, then
"%ObjectPrototype%"
)."base"
, perform OrdinaryCallBindThis(F,
calleeContext, thisArgument)."base"
, return NormalCompletion(thisArgument).The abstract operation FunctionAllocate requires the two arguments functionPrototype and strict. It also accepts one optional argument, functionKind. FunctionAllocate performs the following steps:
"normal"
, "non-constructor"
or "generator"
."normal"
."non-constructor"
, then
"normal"
."generator"
, set the [[ConstructorKind]] internal slot of F to
"derived"
."base"
."derived"
constructors to prevent [[Construct]] from
preallocating a generator instance. Generator instance objects are allocated when EvaluateBody is applied to the
GeneratorBody of a generator function.The abstract operation FunctionInitialize requires the arguments: a function object F, kind which is one of (Normal, Method, Arrow), a parameter list production specified by ParameterList, a body production specified by Body, a Lexical Environment specified by Scope. FunctionInitialize performs the following steps:
length
own property."length"
,
PropertyDescriptor{[[Value]]: len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
true}).The abstract operation FunctionCreate requires the arguments: kind which is one of (Normal, Method, Arrow), a parameter list production specified by ParameterList, a body production specified by Body, a Lexical Environment specified by Scope, a Boolean flag Strict, and optionally, an object prototype. FunctionCreate performs the following steps:
"non-constructor"
."normal"
.The abstract operation GeneratorFunctionCreate requires the arguments: kind which is one of (Normal, Method), a parameter list production specified by ParameterList, a body production specified by Body, a Lexical Environment specified by Scope, and a Boolean flag Strict. GeneratorFunctionCreate performs the following steps:
"generator"
).The abstract operation AddRestrictedFunctionProperties is called with a function object F and Realm Record realm as its argument. It performs the following steps:
"caller"
,
PropertyDescriptor {[[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false,
[[Configurable]]: true})."arguments"
,
PropertyDescriptor {[[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false,
[[Configurable]]: true}).The %ThrowTypeError% intrinsic is an anonymous built-in function object that is defined once for each Realm. When %ThrowTypeError% is called it performs the following steps:
The value of the [[Extensible]] internal slot of a %ThrowTypeError% function is false.
The length
property of a %ThrowTypeError% function has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: false }.
The abstract operation MakeConstructor requires a Function argument F and optionally, a
Boolean writablePrototype and an object prototype. If prototype is provided it is assumed
to already contain, if needed, a "constructor"
property whose value is F. This operation converts
F into a constructor by performing the following steps:
prototype
own property."constructor"
, PropertyDescriptor{[[Value]]: F, [[Writable]]: writablePrototype,
[[Enumerable]]: false, [[Configurable]]: true })."prototype"
, PropertyDescriptor{[[Value]]: prototype, [[Writable]]: writablePrototype,
[[Enumerable]]: false, [[Configurable]]: false}).The abstract operation MakeClassConstructor with argument F performs the following steps:
"normal"
."classConstructor"
.The abstract operation MakeMethod with arguments F and homeObject configures F as a method by performing the following steps:
The abstract operation SetFunctionName requires a Function argument F, a String or Symbol
argument name and optionally a String argument prefix. This operation adds a name
property to F by performing the following steps:
name
own property."["
, description, and "]"
."name"
,
PropertyDescriptor{[[Value]]: name, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
true}).NOTE 1 When an execution context is established for evaluating an ECMAScript function a new function Environment Record is created and bindings for each formal parameter are instantiated in that Environment Record. Each declaration in the function body is also instantiated. If the function's formal parameters do not include any default value initializers then the body declarations are instantiated in the same Environment Record as the parameters. If default value parameter initializers exist, a second Environment Record is created for the body declarations. Formal parameters and functions are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during evaluation of the function body.
FunctionDeclarationInstantiation is performed as follows using arguments func and argumentsList. func is the function object for which the execution context is being established.
"arguments"
is an element of parameterNames, then
"arguments"
is an element of functionNames or if "arguments"
is an element of
lexicalNames, then
"arguments"
)."arguments"
)."arguments"
, ao)."arguments"
to parameterNames.eval
(see 12.3.4.1) can determine whether any var scoped
declarations introduced by the eval code conflict with pre-existing top-level lexically scoped declarations. This
is not needed for strict functions because a strict direct eval
always places all declarations into a
new Environment Record.NOTE 2 B.3.3 provides an extension to the above algorithm that is necessary for backwards compatibility with web browser implementations of ECMAScript that predate ECMAScript 2015.
The built-in function objects defined in this specification may be implemented as either ECMAScript function objects (9.2) whose behaviour is provided using ECMAScript code or as implementation provided exotic function objects whose behaviour is provided in some other manner. In either case, the effect of calling such functions must conform to their specifications. An implementation may also provide additional built-in function objects that are not defined in this specification.
If a built-in function object is implemented as an exotic object it must have the ordinary object behaviour specified in 9.1. All such exotic function objects also have [[Prototype]], [[Extensible]], and [[Realm]] internal slots.
Unless otherwise specified every built-in function object has the %FunctionPrototype% object (19.2.3) as the initial value of its [[Prototype]] internal slot.
The behaviour specified for each built-in function via algorithm steps or other means is the specification of the
function body behaviour for both [[Call]] and [[Construct]] invocations of the function. However, [[Construct]] invocation
is not supported by all built-in functions. For each built-in function, when invoked with [[Call]], the [[Call]]
thisArgument provides the this value, the [[Call]] argumentsList provides
the named parameters, and the NewTarget value is undefined. When invoked with [[Construct]], the
this value is uninitialized, the [[Construct]] argumentsList provides the named
parameters, and the [[Construct]] newTarget parameter provides the NewTarget value. If the built-in function is
implemented as an ECMAScript function object then this specified behaviour
must be implemented by the ECMAScript code that is the body of the function. Built-in functions that are ECMAScript function
objects must be strict mode functions. If a built-in constructor has any [[Call]] behaviour other than throwing a TypeError exception, an ECMAScript implementation of the function must be done in a manner that does
not cause the function's [[FunctionKind]] internal slot
to have the value "classConstructor"
.
Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method
unless otherwise specified in the description of a particular function. When a built-in constructor is called as part of a
new
expression the argumentsList parameter of the invoked [[Construct]] internal method provides the
values for the built-in constructor's named parameters.
Built-in functions that are not constructors do not have a prototype
property unless otherwise specified in
the description of a particular function.
If a built-in function object is not implemented as an ECMAScript function it must provide [[Call]] and [[Construct]] internal methods that conform to the following definitions:
The [[Call]] internal method for a built-in function object F is called with parameters thisArgument and argumentsList, a List of ECMAScript language values. The following steps are taken:
NOTE When calleeContext is removed from the execution context stack it must not be destroyed if it has been suspended and retained by an accessible generator object for later resumption.
The [[Construct]] internal method for built-in function object F is called with parameters argumentsList and newTarget. The steps performed are the same as [[Call]] (see 9.3.1) except that step 9 is replaced by:
9. Let result be the Completion Record that is the result of evaluating F in an implementation defined manner that conforms to the specification of F. The this value is uninitialized, argumentsList provides the named parameters, and newTarget provides the NewTarget value.
The abstract operation CreateBuiltinFunction takes arguments realm, prototype, and steps. The optional argument internalSlotsList is a List of the names of additional internal slots that must be defined as part of the object. If the list is not provided, an empty List is used. CreateBuiltinFunction returns a built-in function object created by the following steps:
Each built-in function defined in this specification is created as if by calling the CreateBuiltinFunction abstract operation, unless otherwise specified.
This specification defines several kinds of built-in exotic objects. These objects generally behave similar to ordinary objects except for a few specific situations. The following exotic objects use the ordinary object internal methods except where it is explicitly specified otherwise below:
A bound function is an exotic object that wraps another function object. A bound function is callable (it has a [[Call]] internal method and may have a [[Construct]] internal method). Calling a bound function generally results in a call of its wrapped function.
Bound function objects do not have the internal slots of ECMAScript function objects defined in Table 27. Instead they have the internal slots defined in Table 28.
Internal Slot | Type | Description |
---|---|---|
[[BoundTargetFunction]] | Callable Object | The wrapped function object. |
[[BoundThis]] | Any | The value that is always passed as the this value when calling the wrapped function. |
[[BoundArguments]] | List of Any | A list of values whose elements are used as the first arguments to any call to the wrapped function. |
Unlike ECMAScript function objects, bound function objects do not use an alternative definition of the [[GetOwnProperty]] internal methods. Bound function objects provide all of the essential internal methods as specified in 9.1. However, they use the following definitions for the essential internal methods of function objects.
When the [[Call]] internal method of an exotic bound function object, F, which was created using the bind function is called with parameters thisArgument and argumentsList, a List of ECMAScript language values, the following steps are taken:
When the [[Construct]] internal method of an exotic bound function object, F that was created using the bind function is called with a list of arguments argumentsList and newTarget, the following steps are taken:
The abstract operation BoundFunctionCreate with arguments targetFunction, boundThis and boundArgs is used to specify the creation of new Bound Function exotic objects. It performs the following steps:
An Array object is an exotic object that gives special treatment to array index property keys (see 6.1.7). A property whose property name is an array index is also called an element.
Every Array object has a length
property whose value is always a nonnegative integer less than 232. The value of the length
property is numerically
greater than the name of every own property whose name is an array index; whenever an own property of an Array object is
created or changed, other properties are adjusted as necessary to maintain this invariant. Specifically, whenever an own
property is added whose name is an array index, the value of the length
property is changed, if necessary, to
be one more than the numeric value of that array index; and whenever the value of the length
property is
changed, every own property whose name is an array index whose value is not smaller than the new length is deleted. This
constraint applies only to own properties of an Array object and is unaffected by length
or array index
properties that may be inherited from its prototypes.
NOTE A String property name P is an array index if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 232−1.
Array exotic objects always have a non-configurable property named "length"
.
Array exotic objects provide an alternative definition for the [[DefineOwnProperty]] internal method. Except for that internal method, Array exotic objects provide all of the other essential internal methods as specified in 9.1.
When the [[DefineOwnProperty]] internal method of an Array exotic object A is called with property key P, and Property Descriptor Desc the following steps are taken:
"length"
, then
"length"
)."length"
, oldLenDesc).The abstract operation ArrayCreate with argument length (a positive integer) and optional argument proto is used to specify the creation of new Array exotic objects. It performs the following steps:
"length"
,
PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: false}).The abstract operation ArraySpeciesCreate with arguments originalArray and length is used to specify the creation of a new Array object using a constructor function that is derived from originalArray. It performs the following steps:
"constructor"
).NOTE If originalArray was created using the standard built-in Array constructor for a Realm that is not the Realm of the running execution context, then a new Array is created using the Realm of the running execution context. This maintains compatibility with Web browsers that have historically had that behaviour for the Array.prototype methods that now are defined using ArraySpeciesCreate.
When the abstract operation ArraySetLength is called with an Array exotic object A, and Property Descriptor Desc the following steps are taken:
"length"
,
Desc)."length"
)."length"
,
newLenDesc)."length"
, newLenDesc)."length"
, newLenDesc)."length"
,
PropertyDescriptor{[[Writable]]: false}). This call will always return true.NOTE In steps 3 and 4, if Desc.[[Value]] is an object then its valueOf
method is called twice. This is legacy
behaviour that was specified with this effect starting with the 2nd Edition of this specification.
A String object is an exotic object that encapsulates a String value and exposes virtual integer indexed data
properties corresponding to the individual code unit elements of the String value. Exotic String objects always have a
data property named "length"
whose value is the number of code unit elements in the encapsulated String
value. Both the code unit data properties and the "length"
property are non-writable and
non-configurable.
Exotic String objects have the same internal slots as ordinary objects. They also have a [[StringData]] internal slot.
Exotic String objects provide alternative definitions for the following internal methods. All of the other exotic String object essential internal methods that are not defined below are as specified in 9.1.
When the [[GetOwnProperty]] internal method of an exotic String object S is called with property key P the following steps are taken:
When the abstract operation StringGetIndexProperty is called with an exotic String object S and with property key P, the following steps are taken:
When the [[HasProperty]] internal method of an exotic String object S is called with property key P, the following steps are taken:
When the [[OwnPropertyKeys]] internal method of a String exotic object O is called the following steps are taken:
The abstract operation StringCreate with arguments value and prototype is used to specify the creation of new exotic String objects. It performs the following steps:
"length"
,
PropertyDescriptor{[[Value]]: length, [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: false }).Most ECMAScript functions make an arguments objects available to their code. Depending upon the characteristics of the function definition, its argument object is either an ordinary object or an arguments exotic object. An arguments exotic object is an exotic object whose array index properties map to the formal parameters bindings of an invocation of its associated ECMAScript function.
Arguments exotic objects have the same internal slots as ordinary objects. They also have a [[ParameterMap]] internal
slot. Ordinary arguments objects also have a [[ParameterMap]] internal slot whose value is always undefined. For ordinary
argument objects the [[ParameterMap]] internal slot is only used by Object.prototype.toString
(19.1.3.6) to identify them as such.
Arguments exotic objects provide alternative definitions for the following internal methods. All of the other exotic arguments object essential internal methods that are not defined below are as specified in 9.1
NOTE 1 For non-strict functions the integer indexed data properties of an arguments object whose numeric name values are less than the number of formal parameters of the corresponding function object initially share their values with the corresponding argument bindings in the function's execution context. This means that changing the property changes the corresponding value of the argument binding and vice-versa. This correspondence is broken if such a property is deleted and then redefined or if the property is changed into an accessor property. For strict mode functions, the values of the arguments object's properties are simply a copy of the arguments passed to the function and there is no dynamic linkage between the property values and the formal parameter values.
NOTE 2 The ParameterMap object and its property values are used as a device for specifying the arguments object correspondence to argument bindings. The ParameterMap object and the objects that are the values of its properties are not directly observable from ECMAScript code. An ECMAScript implementation does not need to actually create or use such objects to implement the specified semantics.
NOTE 3 Arguments objects for strict mode functions define non-configurable accessor
properties named "caller"
and "callee"
which throw a TypeError exception on access. The
"callee"
property has a more specific meaning for non-strict functions and a "caller"
property
has historically been provided as an implementation-defined extension by some ECMAScript implementations. The strict
mode definition of these properties exists to ensure that neither of them is defined in any other manner by conforming
ECMAScript implementations.
The [[GetOwnProperty]] internal method of an arguments exotic object when called with a property key P performs the following steps:
"caller"
and desc.[[Value]] is a strict mode Function object, throw a TypeError
exception.If an implementation does not provide a built-in caller
property for argument exotic objects then step 8
of this algorithm is must be skipped.
The [[DefineOwnProperty]] internal method of an arguments exotic object when called with a property key P and Property Descriptor Desc performs the following steps:
The [[Get]] internal method of an arguments exotic object when called with a property key P and ECMAScript language value Receiver performs the following steps:
The [[Set]] internal method of an arguments exotic object when called with property key P, value V, and ECMAScript language value Receiver performs the following steps:
The [[Delete]] internal method of an arguments exotic object when called with a property key P performs the following steps:
The abstract operation CreateUnmappedArgumentsObject called with an argument argumentsList performs the following steps:
"length"
,
PropertyDescriptor{[[Value]]: len, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]:
true})."caller"
,
PropertyDescriptor {[[Get]]: %ThrowTypeError%, [[Set]]: %ThrowTypeError%, [[Enumerable]]: false, [[Configurable]]:
false})."callee"
,
PropertyDescriptor {[[Get]]: %ThrowTypeError%, [[Set]]: %ThrowTypeError%, [[Enumerable]]: false, [[Configurable]]:
false}).The abstract operation CreateMappedArgumentsObject is called with object func, parsed grammar phrase formals, List argumentsList, and Environment Record env. The following steps are performed:
"length"
,
PropertyDescriptor{[[Value]]: len, [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: true})."callee"
,
PropertyDescriptor {[[Value]]: func, [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: true}).The abstract operation MakeArgGetter called with String name and Environment Record env creates a built-in function object that when executed returns the value bound for name in env. It performs the following steps:
An ArgGetter function is an anonymous built-in function with [[name]] and [[env]] internal slots. When an ArgGetter function f that expects no arguments is called it performs the following steps:
NOTE ArgGetter functions are never directly accessible to ECMAScript code.
The abstract operation MakeArgSetter called with String name and Environment Record env creates a built-in function object that when executed sets the value bound for name in env. It performs the following steps:
An ArgSetter function is an anonymous built-in function with [[name]] and [[env]] internal slots. When an ArgSetter function f is called with argument value it performs the following steps:
NOTE ArgSetter functions are never directly accessible to ECMAScript code.
An Integer Indexed object is an exotic object that performs special handling of integer index property keys.
Integer Indexed exotic objects have the same internal slots as ordinary objects additionally [[ViewedArrayBuffer]], [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.
Integer Indexed Exotic objects provide alternative definitions for the following internal methods. All of the other Integer Indexed exotic object essential internal methods that are not defined below are as specified in 9.1.
When the [[GetOwnProperty]] internal method of an Integer Indexed exotic object O is called with property key P the following steps are taken:
When the [[HasProperty]] internal method of an Integer Indexed exotic object O is called with property key P, the following steps are taken:
When the [[DefineOwnProperty]] internal method of an Integer Indexed exotic object O is called with property key P, and Property Descriptor Desc the following steps are taken:
When the [[Get]] internal method of an Integer Indexed exotic object O is called with property key P and ECMAScript language value Receiver the following steps are taken:
When the [[Set]] internal method of an Integer Indexed exotic object O is called with property key P, value V, and ECMAScript language value Receiver, the following steps are taken:
When the [[OwnPropertyKeys]] internal method of an Integer Indexed exotic object O is called the following steps are taken:
The abstract operation IntegerIndexedObjectCreate with arguments prototype and internalSlotsList is used to specify the creation of new Integer Indexed exotic objects. The argument internalSlotsList is a List of the names of additional internal slots that must be defined as part of the object. IntegerIndexedObjectCreate performs the following steps:
The abstract operation IntegerIndexedElementGet with arguments O and index performs the following steps:
The abstract operation IntegerIndexedElementSet with arguments O, index, and value performs the following steps:
A module namespace object is an exotic object that exposes the bindings exported from an ECMAScript Module (See 15.2.3). There is a one-to-one correspondence between
the String-keyed own properties of a module namespace exotic object and the binding names exported by the Module. The exported bindings include any bindings that are indirectly exported using export
*
export items. Each String-valued own property key is the StringValue of the
corresponding exported binding name. These are the only String-keyed properties of a module namespace exotic object. Each
such property has the attributes {[[Configurable]]: false, [[Enumerable]]: true}. Module namespace objects are not extensible.
Module namespace objects have the internal slots defined in Table 29.
Internal Slot | Type | Description |
---|---|---|
[[Module]] | Module Record | The Module Record whose exports this namespace exposes. |
[[Exports]] | List of String | A List containing the String values of the exported names exposed as own properties of this object. The list is ordered as if an Array of those String values had been sorted using Array.prototype.sort using SortCompare as comparefn. |
Module namespace exotic objects provide alternative definitions for all of the internal methods.
When the [[GetPrototypeOf]] internal method of a module namespace exotic object O is called the following steps are taken:
When the [[SetPrototypeOf]] internal method of a module namespace exotic object O is called with argument V the following steps are taken:
When the [[IsExtensible]] internal method of a module namespace exotic object O is called the following steps are taken:
When the [[PreventExtensions]] internal method of a module namespace exotic object O is called the following steps are taken:
When the [[GetOwnProperty]] internal method of a module namespace exotic object O is called with property key P, the following steps are taken:
When the [[DefineOwnProperty]] internal method of a module namespace exotic object O is called with property key P and Property Descriptor Desc, the following steps are taken:
When the [[HasProperty]] internal method of a module namespace exotic object O is called with property key P, the following steps are taken:
When the [[Get]] internal method of a module namespace exotic object O is called with property key P and ECMAScript language value Receiver the following steps are taken:
"ambiguous"
.NOTE ResolveExport is idempotent and side-effect free. An implementation might choose to pre-compute or cache the ResolveExport results for the [[Exports]] of each module namespace exotic object.
When the [[Set]] internal method of a module namespace exotic object O is called with property key P, value V, and ECMAScript language value Receiver, the following steps are taken:
When the [[Delete]] internal method of a module namespace exotic object O is called with property key P the following steps are taken:
When the [[Enumerate]] internal method of a module namespace exotic object O is called the following steps are taken:
When the [[OwnPropertyKeys]] internal method of a module namespace exotic object O is called the following steps are taken:
The abstract operation ModuleNamespaceCreate with arguments module, and exports is used to specify the creation of new module namespace exotic objects. It performs the following steps:
A proxy object is an exotic object whose essential internal methods are partially implemented using ECMAScript code. Every proxy objects has an internal slot called [[ProxyHandler]]. The value of [[ProxyHandler]] is an object, called the proxy's handler object, or null. Methods (see Table 30) of a handler object may be used to augment the implementation for one or more of the proxy object's internal methods. Every proxy object also has an internal slot called [[ProxyTarget]] whose value is either an object or the null value. This object is called the proxy's target object.
Internal Method | Handler Method |
---|---|
[[GetPrototypeOf]] | getPrototypeOf |
[[SetPrototypeOf]] | setPrototypeOf |
[[IsExtensible]] | isExtensible |
[[PreventExtensions]] | preventExtensions |
[[GetOwnProperty]] | getOwnPropertyDescriptor |
[[HasProperty]] | has |
[[Get]] | get |
[[Set]] | set |
[[Delete]] | deleteProperty |
[[DefineOwnProperty]] | defineProperty |
[[Enumerate]] | enumerate |
[[OwnPropertyKeys]] | ownKeys |
[[Call]] | apply |
[[Construct]] | construct |
When a handler method is called to provide the implementation of a proxy object internal method, the handler method is passed the proxy's target object as a parameter. A proxy's handler object does not necessarily have a method corresponding to every essential internal method. Invoking an internal method on the proxy results in the invocation of the corresponding internal method on the proxy's target object if the handler object does not have a method corresponding to the internal trap.
The [[ProxyHandler]] and [[ProxyTarget]] internal slots of a proxy object are always initialized when the object is created and typically may not be modified. Some proxy objects are created in a manner that permits them to be subsequently revoked. When a proxy is revoked, its [[ProxyHander]] and [[ProxyTarget]] internal slots are set to null causing subsequent invocations of internal methods on that proxy object to throw a TypeError exception.
Because proxy objects permit the implementation of internal methods to be provided by arbitrary ECMAScript code, it is possible to define a proxy object whose handler methods violates the invariants defined in 6.1.7.3. Some of the internal method invariants defined in 6.1.7.3 are essential integrity invariants. These invariants are explicitly enforced by the proxy object internal methods specified in this section. An ECMAScript implementation must be robust in the presence of all possible invariant violations.
In the following algorithm descriptions, assume O is an ECMAScript proxy object, P is a property key value, V is any ECMAScript language value and Desc is a Property Descriptor record.
When the [[GetPrototypeOf]] internal method of a Proxy exotic object O is called the following steps are taken:
"getPrototypeOf"
).NOTE [[GetPrototypeOf]] for proxy objects enforces the following invariant:
The result of [[GetPrototypeOf]] must be either an Object or null.
If the target object is not extensible, [[GetPrototypeOf]] applied to the proxy object must return the same value as [[GetPrototypeOf]] applied to the proxy object's target object.
When the [[SetPrototypeOf]] internal method of a Proxy exotic object O is called with argument V the following steps are taken:
"setPrototypeOf"
).NOTE [[SetPrototypeOf]] for proxy objects enforces the following invariant:
The result of [[SetPrototypeOf]] is a Boolean value.
If the target object is not extensible, the argument value must be the same as the result of [[GetPrototypeOf]] applied to target object.
When the [[IsExtensible]] internal method of a Proxy exotic object O is called the following steps are taken:
"isExtensible"
).NOTE [[IsExtensible]] for proxy objects enforces the following invariant:
The result of [[IsExtensible]] is a Boolean value.
[[IsExtensible]] applied to the proxy object must return the same value as [[IsExtensible]] applied to the proxy object's target object with the same argument.
When the [[PreventExtensions]] internal method of a Proxy exotic object O is called the following steps are taken:
"preventExtensions"
).NOTE [[PreventExtensions]] for proxy objects enforces the following invariant:
The result of [[PreventExtensions]] is a Boolean value.
[[PreventExtensions]] applied to the proxy object only returns true if [[IsExtensible]] applied to the proxy object's target object is false.
When the [[GetOwnProperty]] internal method of a Proxy exotic object O is called with property key P, the following steps are taken:
"getOwnPropertyDescriptor"
).NOTE [[GetOwnProperty]] for proxy objects enforces the following invariants:
The result of [[GetOwnProperty]] must be either an Object or undefined.
A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target object.
A property cannot be reported as non-existent, if it exists as an own property of the target object and the target object is not extensible.
A property cannot be reported as existent, if it does not exists as an own property of the target object and the target object is not extensible.
A property cannot be reported as non-configurable, if it does not exists as an own property of the target object or if it exists as a configurable own property of the target object.
When the [[DefineOwnProperty]] internal method of a Proxy exotic object O is called with property key P and Property Descriptor Desc, the following steps are taken:
"defineProperty"
).NOTE [[DefineOwnProperty]] for proxy objects enforces the following invariants:
The result of [[DefineOwnProperty]] is a Boolean value.
A property cannot be added, if the target object is not extensible.
A property cannot be non-configurable, unless there exists a corresponding non-configurable own property of the target object.
If a property has a corresponding target object property then applying the Property Descriptor of the property to the target object using [[DefineOwnProperty]] will not throw an exception.
When the [[HasProperty]] internal method of a Proxy exotic object O is called with property key P, the following steps are taken:
"has"
).NOTE [[HasProperty]] for proxy objects enforces the following invariants:
The result of [[HasProperty]] is a Boolean value.
A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target object.
A property cannot be reported as non-existent, if it exists as an own property of the target object and the target object is not extensible.
When the [[Get]] internal method of a Proxy exotic object O is called with property key P and ECMAScript language value Receiver the following steps are taken:
"get"
).NOTE [[Get]] for proxy objects enforces the following invariants:
The value reported for a property must be the same as the value of the corresponding target object property if the target object property is a non-writable, non-configurable own data property.
The value reported for a property must be undefined if the corresponding target object property is a non-configurable own accessor property that has undefined as its [[Get]] attribute.
When the [[Set]] internal method of a Proxy exotic object O is called with property key P, value V, and ECMAScript language value Receiver, the following steps are taken:
"set"
).NOTE [[Set]] for proxy objects enforces the following invariants:
The result of [[Set]] is a Boolean value.
Cannot change the value of a property to be different from the value of the corresponding target object property if the corresponding target object property is a non-writable, non-configurable own data property.
Cannot set the value of a property if the corresponding target object property is a non-configurable own accessor property that has undefined as its [[Set]] attribute.
When the [[Delete]] internal method of a Proxy exotic object O is called with property key P the following steps are taken:
"deleteProperty"
).NOTE [[Delete]] for proxy objects enforces the following invariant:
When the [[Enumerate]] internal method of a Proxy exotic object O is called the following steps are taken:
"enumerate"
).NOTE [[Enumerate]] for proxy objects enforces the following invariants:
When the [[OwnPropertyKeys]] internal method of a Proxy exotic object O is called the following steps are taken:
"ownKeys"
).NOTE [[OwnPropertyKeys]] for proxy objects enforces the following invariants:
The result of [[OwnPropertyKeys]] is a List.
The Type of each result List element is either String or Symbol.
The result List must contain the keys of all non-configurable own properties of the target object.
If the target object is not extensible, then the result List must contain all the keys of the own properties of the target object and no other values.
The [[Call]] internal method of a Proxy exotic object O is called with parameters thisArgument and argumentsList, a List of ECMAScript language values. The following steps are taken:
"apply"
).NOTE A Proxy exotic object only has a [[Call]] internal method if the initial value of its [[ProxyTarget]] internal slot is an object that has a [[Call]] internal method.
The [[Construct]] internal method of a Proxy exotic object O is called with parameters argumentsList which is a possibly empty List of ECMAScript language values and newTarget. The following steps are taken:
"construct"
).NOTE 1 A Proxy exotic object only has a [[Construct]] internal method if the initial value of its [[ProxyTarget]] internal slot is an object that has a [[Construct]] internal method.
NOTE 2 [[Construct]] for proxy objects enforces the following invariants:
The abstract operation ProxyCreate with arguments target and handler is used to specify the creation of new Proxy exotic objects. It performs the following steps: