332 lines
7.6 KiB
Markdown
332 lines
7.6 KiB
Markdown
# Object
|
|
|
|
### length <sub>number</sub>
|
|
|
|
### name <sub>string</sub>
|
|
|
|
### prototype <sub>object</sub>
|
|
|
|
### create(proto, propertiesObject) <sub>function</sub>
|
|
|
|
Create a new object, using the specified prototype object and optional property descriptors.
|
|
|
|
|
|
|
|
**proto**: The object to be used as the prototype.
|
|
|
|
**propertiesObject**: Optional. An object specifying properties to be added.
|
|
|
|
|
|
**Returns**: A new object with the given prototype and properties.
|
|
|
|
|
|
### getPrototypeOf(obj) <sub>function</sub>
|
|
|
|
Return the prototype of the specified object. If no prototype is found (e.g. the object has null as its prototype), return null.
|
|
|
|
|
|
|
|
**obj**: The object whose prototype is to be returned.
|
|
|
|
|
|
**Returns**: The prototype of 'obj', or null.
|
|
|
|
|
|
### setPrototypeOf(obj, proto) <sub>function</sub>
|
|
|
|
Set the prototype of the specified object to the provided value. Throws a TypeError if the object is non-extensible and the prototype is changed.
|
|
|
|
|
|
|
|
**obj**: The object whose prototype is set.
|
|
|
|
**proto**: The new prototype or null.
|
|
|
|
|
|
**Returns**: The object 'obj' after setting its prototype.
|
|
|
|
|
|
### defineProperty(obj, prop, descriptor) <sub>function</sub>
|
|
|
|
Define or modify a property on an object using a property descriptor, returning the object. Throws a TypeError if the descriptor is invalid.
|
|
|
|
|
|
|
|
**obj**: The object on which to define or modify a property.
|
|
|
|
**prop**: The name or Symbol of the property.
|
|
|
|
**descriptor**: A property descriptor object (e.g., {value, writable, get, set, ...}).
|
|
|
|
|
|
**Returns**: The object with the newly defined or updated property.
|
|
|
|
|
|
### defineProperties(obj, props) <sub>function</sub>
|
|
|
|
Define new or modify existing properties on an object, given an object of property descriptors. Returns the modified object.
|
|
|
|
|
|
|
|
**obj**: The object on which to define or modify properties.
|
|
|
|
**props**: An object mapping property names to property descriptors.
|
|
|
|
|
|
**Returns**: The modified object.
|
|
|
|
|
|
### getOwnPropertyNames(obj) <sub>function</sub>
|
|
|
|
Return an array of all own (non-Symbol) property names found directly on the given object, in the same order as a for...in loop would return.
|
|
|
|
|
|
|
|
**obj**: The object whose own property names are returned.
|
|
|
|
|
|
**Returns**: An array of strings that correspond to the properties.
|
|
|
|
|
|
### getOwnPropertySymbols(obj) <sub>function</sub>
|
|
|
|
Return an array of all own Symbol properties found directly on the given object.
|
|
|
|
|
|
|
|
**obj**: The object to retrieve Symbol keys from.
|
|
|
|
|
|
**Returns**: An array of Symbol keys.
|
|
|
|
|
|
### groupBy(obj, fn) <sub>function</sub>
|
|
|
|
Non-standard / Proposed. Group the own properties of an object according to the return value of a grouping function. Typically returns a new object whose keys are the group identifiers.
|
|
|
|
|
|
|
|
**obj**: The object to group.
|
|
|
|
**fn**: A function(key, value) => groupingKey, applied to each property.
|
|
|
|
|
|
**Returns**: An object where properties are grouped by the returned keys.
|
|
|
|
|
|
### keys(obj) <sub>function</sub>
|
|
|
|
Return an array of the object's own enumerable (non-Symbol) property names, in the same order that a normal loop would.
|
|
|
|
|
|
|
|
**obj**: The object whose property names are to be returned.
|
|
|
|
|
|
**Returns**: An array of property names.
|
|
|
|
|
|
### values(obj) <sub>function</sub>
|
|
|
|
Return an array of the object's own enumerable (non-Symbol) property values, in the same order as Object.keys().
|
|
|
|
|
|
|
|
**obj**: The object whose property values are to be returned.
|
|
|
|
|
|
**Returns**: An array of property values.
|
|
|
|
|
|
### entries(obj) <sub>function</sub>
|
|
|
|
Return an array of [key, value] pairs for the object's own enumerable (non-Symbol) properties, in the same order as Object.keys().
|
|
|
|
|
|
|
|
**obj**: The object whose [key, value] pairs are to be returned.
|
|
|
|
|
|
**Returns**: An array of [key, value] pairs.
|
|
|
|
|
|
### isExtensible(obj) <sub>function</sub>
|
|
|
|
Return a boolean indicating whether new properties can be added to the specified object.
|
|
|
|
|
|
|
|
**obj**: The object to test.
|
|
|
|
|
|
**Returns**: True if the object is extensible, otherwise false.
|
|
|
|
|
|
### preventExtensions(obj) <sub>function</sub>
|
|
|
|
Prevent new properties from ever being added to an object. Existing properties are not affected.
|
|
|
|
|
|
|
|
**obj**: The object to mark as non-extensible.
|
|
|
|
|
|
**Returns**: The non-extensible object.
|
|
|
|
|
|
### getOwnPropertyDescriptor(obj, prop) <sub>function</sub>
|
|
|
|
Return the property descriptor for a named property on the specified object, if it exists, otherwise undefined.
|
|
|
|
|
|
|
|
**obj**: The object in which to look for the property.
|
|
|
|
**prop**: The name or Symbol of the property.
|
|
|
|
|
|
**Returns**: The property descriptor, or undefined if not found.
|
|
|
|
|
|
### getOwnPropertyDescriptors(obj) <sub>function</sub>
|
|
|
|
Return an object containing all own property descriptors for the given object, keyed by property names (and Symbols).
|
|
|
|
|
|
|
|
**obj**: The object to retrieve property descriptors from.
|
|
|
|
|
|
**Returns**: An object mapping property keys to property descriptors.
|
|
|
|
|
|
### is(value1, value2) <sub>function</sub>
|
|
|
|
Compare two values for strict equality, like '===' but without special treatment for +0 and -0, and treating NaN as equal to NaN.
|
|
|
|
|
|
|
|
**value1**: A value to compare.
|
|
|
|
**value2**: Another value to compare.
|
|
|
|
|
|
**Returns**: True if both values are the same, otherwise false.
|
|
|
|
|
|
### assign(target, sources) <sub>function</sub>
|
|
|
|
Copy all enumerable own properties from one or more source objects to a target object, returning the modified target.
|
|
|
|
|
|
|
|
**target**: The object to receive properties.
|
|
|
|
**sources**: One or more objects containing properties to copy.
|
|
|
|
|
|
**Returns**: The updated target object.
|
|
|
|
|
|
### seal(obj) <sub>function</sub>
|
|
|
|
Seal an object, preventing new properties from being added and marking all existing properties as non-configurable. Values of present properties can still be changed if they are writable.
|
|
|
|
|
|
|
|
**obj**: The object to seal.
|
|
|
|
|
|
**Returns**: The sealed object.
|
|
|
|
|
|
### freeze(obj) <sub>function</sub>
|
|
|
|
Freeze an object, preventing new properties from being added, existing properties from being removed, or current properties from being changed (to the extent permitted by property descriptors).
|
|
|
|
|
|
|
|
**obj**: The object to freeze.
|
|
|
|
|
|
**Returns**: The frozen object.
|
|
|
|
|
|
### isSealed(obj) <sub>function</sub>
|
|
|
|
Check if an object is sealed. A sealed object has no configurable properties and is non-extensible.
|
|
|
|
|
|
|
|
**obj**: The object to test.
|
|
|
|
|
|
**Returns**: True if the object is sealed, otherwise false.
|
|
|
|
|
|
### isFrozen(obj) <sub>function</sub>
|
|
|
|
Check if an object is frozen. A frozen object is sealed and all data properties are non-writable.
|
|
|
|
|
|
|
|
**obj**: The object to test.
|
|
|
|
|
|
**Returns**: True if the object is frozen, otherwise false.
|
|
|
|
|
|
### __getClass() <sub>function</sub>
|
|
|
|
### fromEntries(entries) <sub>function</sub>
|
|
|
|
Transform a list of key-value pairs into an object. The iterable argument should yield pairs [key, value], which become properties on the resulting object.
|
|
|
|
|
|
|
|
**entries**: An iterable of [key, value] pairs.
|
|
|
|
|
|
**Returns**: A new object formed from the given entries.
|
|
|
|
|
|
### hasOwn(obj, prop) <sub>function</sub>
|
|
|
|
Return a boolean indicating whether the specified property exists on the object as a direct own property (similar to hasOwnProperty, but directly on Object).
|
|
|
|
|
|
|
|
**obj**: The object on which to check the property.
|
|
|
|
**prop**: The name or Symbol of the property to check.
|
|
|
|
|
|
**Returns**: True if the property is found on 'obj', otherwise false.
|
|
|
|
|
|
### id(obj) <sub>function</sub>
|
|
|
|
Non-standard. Return a unique identifier for the given object, assigning one if necessary. The same object will always yield the same ID.
|
|
|
|
|
|
|
|
**obj**: The object to retrieve or assign a unique ID.
|
|
|
|
|
|
**Returns**: A unique identifier (string or number) associated with the object.
|
|
|
|
|
|
### mixin(target, source) <sub>function</sub>
|
|
|
|
Copy all property descriptors from 'source' into 'target'.
|
|
|
|
|
|
|
|
**target**: The object that will receive properties.
|
|
|
|
**source**: The object whose properties are to be copied.
|
|
|
|
|
|
**Returns**: The updated 'target' object.
|
|
|