The Object constructor is the %Object% intrinsic object and the initial value of the Object property of
the global object. When called as a constructor it creates a new ordinary object. When Object is called as a
function rather than as a constructor, it performs a type conversion.
The Object constructor is designed to be subclassable. It may be used as the value of an
extends clause of a class definition.
When Object function is called with optional argument value, the following
steps are taken:
"%ObjectPrototype%").The value of the [[Prototype]] internal slot of the Object constructor is the intrinsic object %FunctionPrototype%.
Besides the length property (whose value is 1), the Object constructor has the following
properties:
The assign function is used to copy the values of all of the enumerable own properties from one or more source objects to a target object. When the assign function is called, the following steps are taken:
The length property of the assign method is 2.
The create function creates a new object with a specified prototype. When the create function is called, the following steps are taken:
The defineProperties function is used to add own properties and/or update the attributes of existing own properties of an object. When the defineProperties function is called, the following steps are taken:
The abstract operation ObjectDefineProperties with arguments O and Properties performs the following steps:
The defineProperty function is used to add an own property and/or update the attributes of an existing own property of an object. When the defineProperty function is called, the following steps are taken:
When the freeze function is called, the following steps are taken:
frozen").When the getOwnPropertyDescriptor function is called, the following steps are
taken:
When the getOwnPropertyNames function is called, the following steps are taken:
When the getOwnPropertySymbols function is called with argument O, the following steps are taken:
The abstract operation GetOwnPropertyKeys is called with arguments O and Type where O is an Object and Type is one of the ECMAScript specification types String or Symbol. The following steps are taken:
When the getPrototypeOf function is called with argument O, the following
steps are taken:
When the is function is called with arguments value1 and value2 the following steps are taken:
When the isExtensible function is called with argument O, the following steps are taken:
When the isFrozen function is called with argument O, the following steps are taken:
frozen").When the isSealed function is called with argument O, the following steps are taken:
sealed").When the keys function is called with argument O, the following steps are taken:
If an implementation defines a specific order of enumeration for the for-in statement, the same order must be used for the elements of the array returned in step 4.
When the preventExtensions function is called, the following steps are taken:
The initial value of Object.prototype is the intrinsic object %ObjectPrototype% (19.1.3).
This property has the attributes {[[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
When the seal function is called, the following steps are taken:
sealed").When the setPrototypeOf function is called with arguments O and proto, the following steps are taken:
The Object prototype object is the intrinsic object %ObjectPrototype%. The Object prototype object is an ordinary object.
The value of the [[Prototype]] internal slot of the Object prototype object is null and the initial value of the [[Extensible]] internal slot is true.
The initial value of Object.prototype.constructor is the intrinsic object %Object%.
When the hasOwnProperty method is called with argument V, the following
steps are taken:
NOTE The ordering of steps 1 and 3 is chosen to ensure that any exception that would have been thrown by step 1 in previous editions of this specification will continue to be thrown even if the this value is undefined or null.
When the isPrototypeOf method is called with argument V, the following
steps are taken:
NOTE The ordering of steps 1 and 2 preserves the behaviour specified by previous editions of this specification for the case where V is not an object and the this value is undefined or null.
When the propertyIsEnumerable method is called with argument V, the
following steps are taken:
NOTE 1 This method does not consider objects in the prototype chain.
NOTE 2 The ordering of steps 1 and 3 is chosen to ensure that any exception that would have been thrown by step 1 in previous editions of this specification will continue to be thrown even if the this value is undefined or null.
When the toLocaleString method is called, the following steps are taken:
"toString").The optional parameters to this function are not used but are intended to correspond to the parameter pattern used by
ECMA-402 toLocalString functions. Implementations that do not include ECMA-402 support must not use those
parameter positions for other purposes.
The length property of the toLocaleString method is 0.
NOTE 1 This function provides a generic toLocaleString implementation for
objects that have no locale-specific toString behaviour. Array, Number,
Date, and Typed Arrays provide their own locale-sensitive toLocaleString
methods.
NOTE 2 ECMA-402 intentionally does not provide an alternative to this default implementation.
When the toString method is called, the following steps are taken:
"[object Undefined]"."[object Null]"."Array"."String"."Arguments"."Function"."Error"."Boolean"."Number"."Date"."RegExp"."Object"."[object ", tag, and
"]".This function is the %ObjProto_toString% intrinsic object.
NOTE Historically, this function was occasionally used to access the String value of the
[[Class]] internal slot that was used in previous editions
of this specification as a nominal type tag for various built-in objects. The above definition of toString
preserves compatibility for legacy code that uses toString as a test for those specific kinds of built-in
objects. It does not provide a reliable type testing mechanism for other kinds of built-in or program defined objects.
In addition, programs can use @@toStringTag in ways that will invalidate the reliability of such legacy type tests.
When the valueOf method is called, the following steps are taken:
Object instances have no special properties beyond those inherited from the Object prototype object.
The Function constructor is the %Function% intrinsic object and the initial value of the Function property
of the global object. When Function is called as a function rather than as a constructor, it creates and
initializes a new Function object. Thus the function call Function(…) is equivalent to
the object creation expression new Function(…) with the same arguments.
The Function constructor is designed to be subclassable. It may be used as the value of an
extends clause of a class definition. Subclass constructors that intend to inherit the specified
Function behaviour must include a super call to the Function constructor to create
and initialize a subclass instances with the internal slots necessary for built-in function behaviour. All ECMAScript
syntactic forms for defining function objects create instances of Function. There is no syntactic means to
create instances of Function subclasses except for the built-in Generator Function subclass.
The last argument specifies the body (executable code) of a function; any preceding arguments specify formal parameters.
When the Function function is called with some arguments p1,
p2, … , pn, body (where n might be 0, that is, there are no “p” arguments, and where body might also
not be provided), the following steps are taken:
"normal",
args).NOTE It is permissible but not necessary to have one argument for each formal parameter to be specified. For example, all three of the following expressions produce the same result:
new Function("a", "b", "c", "return a+b+c")
new Function("a, b, c", "return a+b+c")
new Function("a,b", "c", "return a+b+c")
The abstract operation CreateDynamicFunction is called with arguments constructor, newTarget,
kind, and args. constructor is the constructor function that is performing this action,
newTarget is the constructor that new was initially applied to, kind is either
"normal" or "generator", and args is a List containing the actual argument values that were passed to
constructor. The following steps are taken:
"normal", then
"%FunctionPrototype%"."%Generator%"."," (a
comma), and nextArgString."generator", then
"generator", then
"anonymous").NOTE A prototype property is automatically created for every function created
using CreateDynamicFunction , to provide for the possibility that the function will be used as a constructor.
The Function constructor is itself a built-in function object. The value of the [[Prototype]] internal slot of the Function constructor is
%FunctionPrototype%, the intrinsic Function prototype object (19.2.3).
The value of the [[Extensible]] internal slot of the Function constructor is true.
The Function constructor has the following properties:
This is a data property with a value of 1. This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
The value of Function.prototype is %FunctionPrototype%, the intrinsic Function prototype object (19.2.3).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The Function prototype object is the intrinsic object %FunctionPrototype%. The Function prototype object is itself a built-in function object. When invoked, it accepts any arguments and returns undefined. It does not have a [[Construct]] internal method so it is not a constructor.
NOTE The Function prototype object is specified to be a function object to ensure compatibility with ECMAScript code that was created prior to the ECMAScript 2015 specification.
The value of the [[Prototype]] internal slot of the Function prototype object is the intrinsic object %ObjectPrototype% (19.1.3). The initial value of the [[Extensible]] internal slot of the Function prototype object is true.
The Function prototype object does not have a prototype property.
The value of the length property of the Function prototype object is 0.
The value of the name property of the Function prototype object is the empty String.
When the apply method is called on an object func with arguments
thisArg and argArray, the following steps are taken:
The length property of the apply method is 2.
NOTE 1 The thisArg value is passed without modification as the this value. This is a change from Edition 3, where an undefined or null thisArg is replaced with the global object and ToObject is applied to all other values and that result is passed as the this value. Even though the thisArg is passed without modification, non-strict functions still perform these transformations upon entry to the function.
NOTE 2 If func is an arrow function or a bound function then the thisArg will be ignored by the function [[Call]] in step 6.
When the bind method is called with argument thisArg and zero or more
args, it performs the following steps:
"length")."length")."length",
PropertyDescriptor {[[Value]]: L, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
true})."name")."bound").The length property of the bind method is 1.
NOTE 1 Function objects created using Function.prototype.bind are exotic
objects. They also do not have a prototype property.
NOTE 2 If Target is an arrow function or a bound function then the thisArg passed to this method will not be used by subsequent calls to F.
When the call method is called on an object func with argument,
thisArg and zero or more args, the following steps are taken:
The length property of the call method is 1.
NOTE 1 The thisArg value is passed without modification as the this value. This is a change from Edition 3, where an undefined or null thisArg is replaced with the global object and ToObject is applied to all other values and that result is passed as the this value. Even though the thisArg is passed without modification, non-strict functions still perform these transformations upon entry to the function.
NOTE 2 If func is an arrow function or a bound function then the thisArg will be ignored by the function [[Call]] in step 5.
The initial value of Function.prototype.constructor is the intrinsic object %Function%.
When the toString method is called on an object func the following steps
are taken:
toString Representation Requirements:
The string representation must have the syntax of a FunctionDeclaration, FunctionExpression, GeneratorDeclaration, GeneratorExpression, ClassDeclaration, ClassExpression, ArrowFunction, MethodDefinition, or GeneratorMethod depending upon the actual characteristics of the object.
The use and placement of white space, line terminators, and semicolons within the representation String is implementation-dependent.
If the object was defined using ECMAScript code and the returned string representation is not in the form of a
MethodDefinition or GeneratorMethod then the representation must be such that if the string is
evaluated, using eval in a lexical context that is equivalent to the lexical context used to create the
original object, it will result in a new functionally equivalent object. In that case the returned source code must
not mention freely any variables that were not mentioned freely by the original function's source code, even if
these “extra” names were originally in scope.
If the implementation cannot produce a source code string that meets these criteria then it must return a string
for which eval will throw a SyntaxError
exception.
When the @@hasInstance method of an object F is called with value V, the following steps are taken:
The value of the name property of this function is "[Symbol.hasInstance]".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
NOTE This is the default implementation of @@hasInstance that most functions
inherit. @@hasInstance is called by the instanceof operator to determine whether a value is an
instance of a specific constructor. An expression such as
v instanceof F
evaluates as
F[@@hasInstance](v)
A constructor function can control which objects are recognized as its instances by instanceof by
exposing a different @@hasInstance method on the function.
This property is non-writable and non-configurable to prevent tampering that could be used to globally expose the target function of a bound function.
Every function instance is an ECMAScript function object and has the
internal slots listed in Table 27. Function instances created using the Function.prototype.bind method (19.2.3.2) have the internal slots listed in Table 28.
The Function instances have the following properties:
The value of the length property is an integer that indicates the typical number of arguments expected by
the function. However, the language permits the function to be invoked with some other number of arguments. The behaviour
of a function when invoked on a number of arguments other than the number specified by its length property
depends on the function. This property has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
The value of the name property is an String that is descriptive of the function. The name has no semantic
significance but is typically a variable or property name that is used to refer to the function at its point of definition
in ECMAScript code. This property has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
Anonymous functions objects that do not have a contextual name associated with them by this specification do not have a
name own property but inherit the name property of %FunctionPrototype%.
Function instances that can be used as a constructor have a prototype property. Whenever such a function
instance is created another ordinary object is also created and is the initial value of the function’s
prototype property. Unless otherwise specified, the value of the prototype property is used to
initialize the [[Prototype]] internal slot of the object
created when that function is invoked as a constructor.
This property has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }.
NOTE Function objects created using Function.prototype.bind, or by evaluating a MethodDefinition (that are not a GeneratorMethod) or an ArrowFunction grammar production do not have a prototype property.
The Boolean constructor is the %Boolean% intrinsic object and the initial value of the Boolean property of
the global object. When called as a constructor it creates and initializes a new Boolean object. When Boolean
is called as a function rather than as a constructor, it performs a type conversion.
The Boolean constructor is designed to be subclassable. It may be used as the value of an
extends clause of a class definition. Subclass constructors that intend to inherit the specified
Boolean behaviour must include a super call to the Boolean constructor to create
and initialize the subclass instance with a [[BooleanData]] internal slot.
When Boolean is called with argument value, the following steps are
taken:
"%BooleanPrototype%", «[[BooleanData]]» ).The value of the [[Prototype]] internal slot of the Boolean constructor is the intrinsic object %FunctionPrototype% (19.2.3).
Besides the length property (whose value is 1), the Boolean constructor has the following
properties:
The initial value of Boolean.prototype is the intrinsic object %BooleanPrototype% (19.3.3).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The Boolean prototype object is the intrinsic object %BooleanPrototype%. The Boolean prototype object is an ordinary object. It is not a Boolean instance and does not have a [[BooleanData]] internal slot.
The value of the [[Prototype]] internal slot of the Boolean prototype object is the intrinsic object %ObjectPrototype% (19.1.3).
The abstract operation thisBooleanValue(value) performs the following steps:
The initial value of Boolean.prototype.constructor is the intrinsic object %Boolean%.
The following steps are taken:
"true"; else return "false".The following steps are taken:
Boolean instances are ordinary objects that inherit properties from the Boolean prototype object. Boolean instances have a [[BooleanData]] internal slot. The [[BooleanData]] internal slot is the Boolean value represented by this Boolean object.
The Symbol constructor is the %Symbol% intrinsic object and the initial value of the Symbol property of
the global object. When Symbol is called as a function, it returns a new Symbol value.
The Symbol constructor is not intended to be used with the new operator or to be subclassed.
It may be used as the value of an extends clause of a class definition but a super call to the
Symbol constructor will cause an exception.
When Symbol is called with optional argument description, the following
steps are taken:
The value of the [[Prototype]] internal slot of the Symbol constructor is the intrinsic object %FunctionPrototype% (19.2.3).
Besides the length property (whose value is 0), the Symbol constructor has the
following properties:
When Symbol.for is called with argument key it performs the following
steps:
The GlobalSymbolRegistry is a List that is globally available. It is shared by all Code Realms. Prior to the evaluation of any ECMAScript code it is initialized as an empty List. Elements of the GlobalSymbolRegistry are Records with the structure defined in Table 44.
| Field Name | Value | Usage |
|---|---|---|
| [[key]] | A String | A string key used to globally identify a Symbol. |
| [[symbol]] | A Symbol | A symbol that can be retrieved from any Realm. |
The initial value of Symbol.hasInstance is the well known symbol @@hasInstance (Table
1).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of Symbol.isConcatSpreadable is the well known symbol @@isConcatSpreadable (Table 1).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of Symbol.iterator is the well known symbol @@iterator (Table
1).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
When Symbol.keyFor is called with argument sym it performs the following
steps:
The initial value of Symbol.match is the well known symbol @@match (Table 1).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of Symbol.prototype is the intrinsic object %SymbolPrototype% (19.4.3).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of Symbol.replace is the well known symbol @@replace (Table
1).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of Symbol.search is the well known symbol @@search (Table 1).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of Symbol.species is the well known symbol @@species (Table
1).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of Symbol.split is the well known symbol @@split (Table 1).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of Symbol.toPrimitive is the well known symbol @@toPrimitive (Table
1).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of Symbol.toStringTag is the well known symbol @@toStringTag (Table
1).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The initial value of Symbol.unscopables is the well known symbol @@unscopables (Table
1).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The Symbol prototype object is the intrinsic object %SymbolPrototype%. The Symbol prototype object is an ordinary object. It is not a Symbol instance and does not have a [[SymbolData]] internal slot.
The value of the [[Prototype]] internal slot of the Symbol prototype object is the intrinsic object %ObjectPrototype% (19.1.3).
The initial value of Symbol.prototype.constructor is the intrinsic object %Symbol%.
The following steps are taken:
When the abstract operation SymbolDescriptiveString is called with argument sym, the following steps are taken:
The following steps are taken:
This function is called by ECMAScript language operators to convert a Symbol object to a primitive value. The allowed
values for hint are "default", "number", and "string".
When the @@toPrimitive method is called with argument hint, the following
steps are taken:
The value of the name property of this function is "[Symbol.toPrimitive]".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
The initial value of the @@toStringTag property is the String value "Symbol".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
Symbol instances are ordinary objects that inherit properties from the Symbol prototype object. Symbol instances have a [[SymbolData]] internal slot. The [[SymbolData]] internal slot is the Symbol value represented by this Symbol object.
Instances of Error objects are thrown as exceptions when runtime errors occur. The Error objects may also serve as base objects for user-defined exception classes.
The Error constructor is the %Error% intrinsic object and the initial value of the Error property of the
global object. When Error is called as a function rather than as a constructor, it creates and initializes a
new Error object. Thus the function call Error(…) is equivalent to the object creation
expression new Error(…) with the same arguments.
The Error constructor is designed to be subclassable. It may be used as the value of an
extends clause of a class definition. Subclass constructors that intend to inherit the specified
Error behaviour must include a super call to the Error constructor to create and
initialize subclass instances with a [[ErrorData]] internal
slot.
When the Error function is called with argument message the following steps
are taken:
"%ErrorPrototype%", «[[ErrorData]]»).message", msgDesc).The value of the [[Prototype]] internal slot of the Error constructor is the intrinsic object %FunctionPrototype% (19.2.3).
Besides the length property (whose value is 1), the Error constructor has the
following properties:
The initial value of Error.prototype is the intrinsic object %ErrorPrototype% (19.5.3).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The Error prototype object is the intrinsic object %ErrorPrototype%. The Error prototype object is an ordinary object. It is not an Error instance and does not have an [[ErrorData]] internal slot.
The value of the [[Prototype]] internal slot of the Error prototype object is the intrinsic object %ObjectPrototype% (19.1.3).
The initial value of Error.prototype.constructor is the intrinsic object %Error%.
The initial value of Error.prototype.message is the empty String.
The initial value of Error.prototype.name is "Error".
The following steps are taken:
"name")."Error"; otherwise let name be ToString(name)."message").Error instances are ordinary objects that inherit properties from the Error prototype object and have an [[ErrorData]] internal slot whose value is undefined. The only specified uses of [[ErrorData]] is to identify Error and NativeError
instances as Error objects within Object.prototype.toString.
A new instance of one of the NativeError objects below is thrown when a runtime error is detected. All of these objects share the same structure, as described in 19.5.6.
This exception is not currently used within this specification. This object remains for compatibility with previous editions of this specification.
Indicates a value that is not in the set or range of allowable values.
Indicate that an invalid reference value has been detected.
Indicates that a parsing error has occurred.
Indicates the actual type of an operand is different than the expected type.
Indicates that one of the global URI handling functions was used in a way that is incompatible with its definition.
When an ECMAScript implementation detects a runtime error, it throws a new instance of one of the NativeError
objects defined in 19.5.5. Each of these objects has the
structure described below, differing only in the name used as the constructor name instead of NativeError, in the
name property of the prototype object, and in the implementation-defined message property of the
prototype object.
For each error object, references to NativeError in the definition should be replaced with the appropriate error object name from 19.5.5.
When a NativeError constructor is called as a function rather than as a constructor, it creates and
initializes a new NativeError object. A call of the object as a function is equivalent to calling it as a
constructor with the same arguments. Thus the function call NativeError(…) is
equivalent to the object creation expression new NativeError(…)
with the same arguments.
Each NativeError constructor is designed to be subclassable. It may be used as the value of an
extends clause of a class definition. Subclass constructors that intend to inherit the specified
NativeError behaviour must include a super call to the NativeError constructor to create and
initialize subclass instances with a [[ErrorData]] internal
slot.
When a NativeError function is called with argument message the following steps are taken:
"%NativeErrorPrototype%", «[[ErrorData]]» ).message", msgDesc).The actual value of the string passed in step 2 is either "%EvalErrorPrototype%",
"%RangeErrorPrototype%", "%ReferenceErrorPrototype%", "%SyntaxErrorPrototype%",
"%TypeErrorPrototype%", or "%URIErrorPrototype%" corresponding to which NativeError
constructor is being defined.
The value of the [[Prototype]] internal slot of a NativeError constructor is the intrinsic object %Error% (19.5.1).
Besides the length property (whose value is 1), each NativeError constructor has the
following properties:
The initial value of NativeError.prototype is a NativeError prototype object (19.5.6.3). Each NativeError constructor has a
distinct prototype object.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
Each NativeError prototype object is an ordinary object. It is not an Error instance and does not have an [[ErrorData]] internal slot.
The value of the [[Prototype]] internal slot of each NativeError prototype object is the intrinsic object %ErrorPrototype% (19.5.3).
The initial value of the constructor property of the prototype for a given NativeError
constructor is the corresponding intrinsic object %NativeError% (19.5.6.1).
The initial value of the message property of the prototype for a given NativeError constructor is
the empty String.
The initial value of the name property of the prototype for a given NativeError constructor is a
string consisting of the name of the constructor (the name used instead of NativeError).
NativeError instances are ordinary objects that inherit properties from their NativeError prototype
object and have an [[ErrorData]] internal slot whose value
is undefined. The only specified use of [[ErrorData]] is by Object.prototype.toString (19.1.3.6) to identify Error or NativeError instances.