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