All objects have an internal slot named [[ClassBrands]],
which is a
Every grammar production alternative in this specification which is not listed below implicitly has the following default definition of Contains:
Static semantic rules that depend upon substructure generally do not look into function definitions except for
super
or this
, return super
, or this
, return super
, or this
, return Contains is used to detect new.target
, class.hasInstance
, this
, and super
usage within an
A class Environment Record is a declarative class.hasInstance
meta method invocations from within the class.
Class Environment Records have the additional state fields listed in
Field Name | Value | Meaning |
---|---|---|
[[ClassConstructor]] | Object |
The class |
Class Environment Records support all of the declarative
The abstract operation NewClassEnvironment takes argument E (an
The abstract operation GetClassEnvironment takes no arguments. It finds the
ECMAScript function objects encapsulate parameterized ECMAScript code closed over a lexical environment and support the dynamic evaluation of that code. An ECMAScript
In addition to [[Extensible]] and [[Prototype]], ECMAScript function objects also have the internal slots listed in
Internal Slot | Type | Description |
---|---|---|
[[Environment]] |
|
The |
[[PrivateEnvironment]] |
PrivateEnvironment |
The PrivateEnvironment |
[[FormalParameters]] |
|
The root parse node of the source text that defines the function's formal parameter list. |
[[ECMAScriptCode]] |
|
The root parse node of the source text that defines the function's body. |
[[ConstructorKind]] |
|
Whether or not the function is a derived class |
[[Realm]] |
|
The |
[[ScriptOrModule]] |
|
The script or module in which the function was created. |
[[ThisMode]] |
|
Defines how this references are interpreted within the formal parameters and code body of the function. this refers to the |
[[Strict]] | Boolean |
|
[[HomeObject]] | Object |
If the function uses super , this is the object whose [[GetPrototypeOf]] provides the object where super property lookups begin.
|
[[SourceText]] | sequence of Unicode code points |
The |
[[Fields]] |
|
If the function is a class, this is a list of Records representing the non-static fields and corresponding initializers of the class. |
[[PrivateMethods]] |
|
If the function is a class, this is a list representing the non-static private methods and accessors of the class. |
[[ClassFieldInitializerName]] |
String | Symbol | Private Name | |
If the function is created as the initializer of a class field, the name to use for NamedEvaluation of the field; |
[[IsClassConstructor]] | Boolean |
Indicates whether the function is a class |
[[ClassBrand]] |
a globally unique value | |
If the function is a class, this might be a globally unique value; |
The abstract operation OrdinaryFunctionCreate takes arguments functionPrototype (an Object), sourceText (a sequence of Unicode code points), ParameterList (a
It is a Syntax Error if
It is a Syntax Error if
For ease of specification, private methods and accessors are included alongside private fields in the [[PrivateElements]] slot of class instances. However, any given object has either all or none of the private methods and accessors defined by a given class. This feature has been designed so that implementations may choose to implement private methods and accessors using a strategy which does not require tracking each method or accessor individually.
For example, an implementation could directly associate instance private methods with their corresponding Private Name and track, for each object, which class constructors have run with that object as their this
value. Looking up an instance private method on an object then consists of checking that the class
This differs from private fields: because field initializers can throw during class instantiation, an individual object may have some proper subset of the private fields of a given class, and so private fields must in general be tracked individually.
constructor(...args) { super(...args); }
. The most notable distinction is that while the aforementioned ECMAScript source text observably calls the @@iterator method on %Array.prototype%
, this function does not.constructor() {}
.super
unless the source code containing super
is eval code that is being processed by a super
within super
.
© 2022 HE Shi-Jun, XU Tian-Yang, Tu Qiang
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.