Class Object

The Object object is the foundation of all native JavaScript objects. Also, the Object object can be used to generate items in your scripts with behaviors that are defined by custom properties and/or methods. You generally start by creating a blank object with the constructor function and then assign values to new properties of that object.

ConstructorDescription
Object()Object constructor.
MethodDescription
static assign(Object, Object...)Copies the values of all of the enumerable own properties from one or more source objects to a target object.
static create(Object)Creates a new object based on a prototype object.
static create(Object, Object)Creates a new object based on a prototype object and additional property definitions.
static defineProperties(Object, Object)Defines or modifies properties of the passed object.
static defineProperty(Object, Object, Object)Defines or modifies a single property of the passed object.
static entries(Object)Returns the enumerable property names and their values of the passed object.
static freeze(Object)Freezes the passed object.
static fromEntries(Iterable)Creates a new object with defined properties.
static getOwnPropertyDescriptor(Object, Object)Returns the descriptor for a single property of the passed object.
static getOwnPropertyNames(Object)Returns an arrays containing the names of all enumerable and non-enumerable properties owned by the passed object.
static getOwnPropertySymbols(Object)Returns an array containing the symbol of all symbol properties owned by the passed object.
static getPrototypeOf(Object)Returns the prototype of the passed object.
hasOwnProperty(String)Returns Boolean true if at the time the current object's instance was created its constructor (or literal assignment) contained a property with a name that matches the parameter value.
static is(Object, Object)Checks if the two values are equal in terms of being the same value.
static isExtensible(Object)Returns if new properties can be added to an object.
static isFrozen(Object)Returns if the object is frozen.
isPrototypeOf(Object)Returns true if the current object and the object passed as a prameter conincide at some point along each object's prototype inheritance chain.
static isSealed(Object)Returns if the object is sealed.
static keys(Object)Returns the enumerable property names of the passed object.
static preventExtensions(Object)Makes the passed object non-extensible.
propertyIsEnumerable(String)Return true if the specified property exposes itself to for/in property inspection through the object.
static seal(Object)Seals the passed object.
static setPrototypeOf(Object, Object)Changes the prototype of the passed object.
toLocaleString()Converts the object to a localized String.
toString()Converts the object to a String.
valueOf()Returns the object's value.
static values(Object)Returns the enumerable property values of the passed object.
Object()

Object constructor.


static assign(target: Object, sources: Object...): Object

Copies the values of all of the enumerable own properties from one or more source objects to a target object.

Parameters:

  • target - The target object.
  • sources - The source objects.

Returns:

  • The target object.

API Version:

Available from version 21.2.


static create(prototype: Object): Object

Creates a new object based on a prototype object.

Parameters:

  • prototype - The prototype for the new object.

Returns:

  • The newly created object.

static create(prototype: Object, properties: Object): Object

Creates a new object based on a prototype object and additional property definitions. The properties are given in the same format as described for defineProperties(Object, Object).

Parameters:

  • prototype - The prototype for the new object.
  • properties - The property definitions.

Returns:

  • The newly created object.

static defineProperties(object: Object, properties: Object): Object

Defines or modifies properties of the passed object. A descriptor for a property supports these properties: configurable, enumerable, value, writable, set and get.

Parameters:

  • object - The object to change.
  • properties - The new property definitions.

Returns:

  • The modified object.

static defineProperty(object: Object, propertyKey: Object, descriptor: Object): Object

Defines or modifies a single property of the passed object. A descriptor for a property supports these properties: configurable, enumerable, value, writable, set and get.

Parameters:

  • object - The object to change.
  • propertyKey - The property name.
  • descriptor - The property descriptor object.

Returns:

  • The modified object.

static entries(object: Object): Array

Returns the enumerable property names and their values of the passed object.

Parameters:

  • object - The object to get the enumerable property names from.

Returns:

  • An array of key/value pairs ( as two element arrays ) that holds all the enumerable properties of the given object.

API Version:

Available from version 22.7.


static freeze(object: Object): Object

Freezes the passed object. Properties can't be added or removed from the frozen object. Also, definitions of existing object properties can't be changed. Although property values are immutable, setters and getters can be called.

Parameters:

  • object - The object to be frozen.

Returns:

  • The frozen object.

static fromEntries(properties: Iterable): Object

Creates a new object with defined properties. The properties are defined by an iterable that produces two element array like objects, which are the key-value pairs. Iterables are e.g. Array, Map or any other Iterable.

Parameters:

  • properties - The properties.

Returns:

  • The newly created object.

API Version:

Available from version 22.7.


static getOwnPropertyDescriptor(object: Object, propertyKey: Object): Object

Returns the descriptor for a single property of the passed object.

Parameters:

  • object - The property owning object.
  • propertyKey - The property to look for.

Returns:

  • The descriptor object for the property or undefined if the property does not exist.

static getOwnPropertyNames(object: Object): Array

Returns an arrays containing the names of all enumerable and non-enumerable properties owned by the passed object.

Parameters:

  • object - The object owning properties.

Returns:

  • An array of strings that are the properties found directly in the passed object.

static getOwnPropertySymbols(object: Object): Array

Returns an array containing the symbol of all symbol properties owned by the passed object.

Parameters:

  • object - The object owning properties.

Returns:

  • An array of symbol properties found directly in the passed object.

API Version:

Available from version 21.2.


static getPrototypeOf(object: Object): Object

Returns the prototype of the passed object.

Parameters:

  • object - The object to get the prototype from.

Returns:

  • The prototype object or null if there is none.

hasOwnProperty(propName: String): Boolean

Returns Boolean true if at the time the current object's instance was created its constructor (or literal assignment) contained a property with a name that matches the parameter value.

Parameters:

  • propName - the property name of the object's property.

Returns:

  • true if at the object contains a property that matches the parameter, false otherwise.

static is(value1: Object, value2: Object): Boolean

Checks if the two values are equal in terms of being the same value. No coercion is performed, thus -0 and +0 is not equal and NaN is equal to NaN.

Parameters:

  • value1 - The first value.
  • value2 - The second value.

Returns:

  • true if both values are the same value else false.

API Version:

Available from version 21.2.


static isExtensible(object: Object): Boolean

Returns if new properties can be added to an object. By default new objects are extensible. The methods freeze(Object), seal(Object) and preventExtensions(Object) make objects non-extensible.

Parameters:

  • object - The object to check.

Returns:

  • true if new properties can be added else false.

static isFrozen(object: Object): Boolean

Returns if the object is frozen.

Parameters:

  • object - The object to check.

Returns:

  • true if the object is frozen else false.

isPrototypeOf(prototype: Object): Boolean

Returns true if the current object and the object passed as a prameter conincide at some point along each object's prototype inheritance chain.

Parameters:

  • prototype - the object to test.

Returns:

  • true if the current object and the object passed as a prameter conincide at some point, false otherwise.

static isSealed(object: Object): Boolean

Returns if the object is sealed.

Parameters:

  • object - The object to check.

Returns:

  • true if the object is sealed else false.

static keys(object: Object): Array

Returns the enumerable property names of the passed object.

Parameters:

  • object - The object to get the enumerable property names from.

Returns:

  • An array of strings that holds all the enumerable properties of the given object.

static preventExtensions(object: Object): Object

Makes the passed object non-extensible. This means that no new properties can be added to this object.

Parameters:

  • object - The object to make non-extensible.

Returns:

  • The passed object.

propertyIsEnumerable(propName: String): Boolean

Return true if the specified property exposes itself to for/in property inspection through the object.

Parameters:

  • propName - the property to test.

Returns:

  • true if the specified property exposes itself to for/in property inspection through the object, false otherwise.

static seal(object: Object): Object

Seals the passed object. This means properties can't be added or removed. Also, property definitions of existing properties can't be changed.

Parameters:

  • object - The object to be frozen.

Returns:

  • The sealed object.

static setPrototypeOf(object: Object, prototype: Object): Object

Changes the prototype of the passed object.

Parameters:

  • object - The object whose prototype should change.
  • prototype - The object to set as the new prototype.

Returns:

  • The object with the changed prototype.

API Version:

Available from version 21.2.


toLocaleString(): String

Converts the object to a localized String.

Returns:

  • a localized version of the object.

toString(): String

Converts the object to a String.

Returns:

  • the String representation of the object.

valueOf(): Object

Returns the object's value.

Returns:

  • the object's value.

static values(object: Object): Array

Returns the enumerable property values of the passed object.

Parameters:

  • object - The object to get the enumerable property values from.

Returns:

  • An array of values that holds all the enumerable properties of the given object.

API Version:

Available from version 22.7.