Object
Last updated
Last updated
The Object type is used to store various keyed collections and more complex entities. Nearly all objects in JavaScript are instances of Object.
For more information see: Object (MDN).
Type | Name | Summary |
---|---|---|
Copy the values of all enumerable own properties from one or more source objects to a target object.
Parameters
Returns: Object The target object.
Sample
Creates a new object, using an existing object to provide the newly created object's prototype.
Parameters
Object object The object which should be the prototype of the newly-created object.
Returns: Object A new object with the specified prototype object.
Sample
Creates a new object, using an existing object to provide the newly created object's prototype and properties.
Parameters
Object object The object which should be the prototype of the newly-created object.
Object properties ;
Returns: Object A new object with the specified prototype object.
Sample
Defines new or modifies existing properties directly on an object, returning the object.
Parameters
Object object The object on which to define or modify properties.
Object properties An object whose own enumerable properties constitute descriptors for the properties to be defined or modified. Descriptors have the following keys: configurable - true if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object. Defaults to false. enumerable - true if and only if this property shows up during enumeration of the properties on the corresponding object. Defaults to false. value - The value associated with the property. Can be any valid JavaScript value (number, object, function, etc). Defaults to undefined. writable - true if and only if the value associated with the property may be changed with an assignment operator. Defaults to false. get - A function which serves as a getter for the property, or undefined if there is no getter. The function return will be used as the value of property. Defaults to undefined. set - A function which serves as a setter for the property, or undefined if there is no setter. The function will receive as only argument the new value being assigned to the property. Defaults to undefined.
Returns: Object The object that was passed to the function.
Sample
Allows a precise addition to or modification of a property on an object.
Parameters
Object object The object on which to define or modify properties.
Object property The name of the property to be defined or modified.
Object descriptor The descriptor for the property being defined or modified.
Returns: Object The object that was passed to the function.
Sample
Returns an array whose elements are arrays corresponding to the enumerable string-keyed property key-value pairs found directly upon object.
Parameters
Object object1 An object.
Returns: Array An array of the given object's own enumerable string-keyed property key-value pairs. Each key-value pair is an array with two elements: the first element is the property key (which is always a string), and the second element is the property value.
Sample
Freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being removed; and prevents existing properties, or their enumerability, configurability, or writability, from being changed. In essence the object is made effectively immutable.
Parameters
Object object The object to freeze.
Returns: Object The object that was passed to the function.
Sample
Transforms a list of key-value pairs into an object
Parameters
Array entries A list of objects. Each object is an array with two values, first value is the key second one is the value.
Returns: Object A new object whose properties are given by the entries of the array.
Sample
Permits examination of the precise description of a property.
Parameters
Object object The object in which to look for the property.
Object property The name of the property whose description is to be retrieved.
Returns: Object A property descriptor of the given property if it exists on the object, undefined otherwise.
Sample
Returns an array of all properties (including non-enumerable properties) found directly upon a given object.
Parameters
Object object The object whose enumerable and non-enumerable own properties are to be returned.
Returns: Array An array of strings that correspond to the properties found directly upon the given object.
Sample
Returns the prototype of the specified object.
Parameters
Object object The object whose prototype is to be returned.
Returns: Object The prototype of the given object. If there are no inherited properties, null is returned.
Sample
Determine whether the object has the specified property as its own property (as opposed to inheriting it).
Parameters
String prop The name of the property to test.
Returns: Boolean A Boolean indicating whether or not the object has the specified property as own property.
Sample
Determines whether two values are the same value.
Parameters
Returns: Boolean a Boolean indicating whether or not the two arguments are the same value.
Sample
Determines if an object is extensible (whether it can have new properties added to it). Objects are extensible by default, can be marked as non-extensible using Object.preventExtensions(), Object.seal(), or Object.freeze().
Parameters
Object object The object which should be checked.
Returns: Boolean A Boolean indicating whether or not the given object is extensible.
Sample
Determines if an object is frozen. An object is frozen if and only if it is not extensible, all its properties are non-configurable, and all its data properties (that is, properties which are not accessor properties with getter or setter components) are non-writable.
Parameters
Object object The object which should be checked.
Returns: Boolean A Boolean indicating whether or not the given object is frozen.
Sample
Checks if an object exists in another object's prototype chain.
Parameters
Object object The object whose prototype chain will be searched.
Returns: Boolean A Boolean indicating whether the calling object lies in the prototype chain of the specified object.
Sample
Determines if an object is sealed. An object is sealed if it is not extensible and if all its properties are non-configurable and therefore not removable (but not necessarily non-writable).
Parameters
Object object The object which should be checked.
Returns: Boolean A Boolean indicating whether or not the given object is sealed.
Sample
Returns an array of all own enumerable properties found upon a given object, in the same order as that provided by a for-in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).
Parameters
Object object An array of strings that represent all the enumerable properties of the given object.
Returns: Array The object of which the enumerable's own properties are to be returned.
Sample
Prevents new properties from ever being added to an object (i.e. prevents future extensions to the object).
Parameters
Object object The object which should be made non-extensible.
Returns: Object The object being made non-extensible.
Sample
Indicates whether the specified property is enumerable.
Parameters
Object prop The name or symbol of the property to test.
Returns: Boolean A Boolean indicating whether the specified property is enumerable.
Sample
Seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable.
Parameters
Object object The object which should be sealed.
Returns: Object The object being sealed.
Sample
Sets the prototype of a specified object to another object or null.
Parameters
Object obj The object which is to have its prototype set.
Object prototype The object's new prototype (an object or null).
Returns: void
Sample
Returns a string representing the object. This method is meant to be overriden by derived objects for locale-specific purposes.
Returns: String A string representing the object.
Sample
Returns a string representing the specified object.
Returns: String A string representing the object.
Sample
Returns the primitive value of the specified object. By default, the valueOf method is inherited by every object descended from Object. Every built-in core object overrides this method to return an appropriate value. If an object has no primitive value, valueOf returns the object itself.
Returns: Object The primitive value of the specified object.
Sample
Returns an array whose elements are strings corresponding to the enumerable string-keyed property values found directly upon object.
Parameters
Object object1 An object.
Returns: Array an array of a given object's own enumerable string-keyed property values.
Sample
Copy the values of all enumerable own properties from one or more source objects to a target object.
Creates a new object, using an existing object to provide the newly created object's prototype.
Creates a new object, using an existing object to provide the newly created object's prototype and properties.
Defines new or modifies existing properties directly on an object, returning the object.
Allows a precise addition to or modification of a property on an object.
Returns an array whose elements are arrays corresponding to the enumerable string-keyed property key-value pairs found directly upon object.
Freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being removed; and prevents existing properties, or their enumerability, configurability, or writability, from being changed.
Transforms a list of key-value pairs into an object
Permits examination of the precise description of a property.
Returns an array of all properties (including non-enumerable properties) found directly upon a given object.
Returns the prototype of the specified object.
Determine whether the object has the specified property as its own property (as opposed to inheriting it).
Determines whether two values are the same value.
Determines if an object is extensible (whether it can have new properties added to it).
Determines if an object is frozen.
Checks if an object exists in another object's prototype chain.
Determines if an object is sealed.
Returns an array of all own enumerable properties found upon a given object, in the same order as that provided by a for-in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).
Prevents new properties from ever being added to an object (i.
Indicates whether the specified property is enumerable.
Seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable.
void
Sets the prototype of a specified object to another object or null.
Returns a string representing the object.
Returns a string representing the specified object.
Returns the primitive value of the specified object.
Returns an array whose elements are strings corresponding to the enumerable string-keyed property values found directly upon object.