Class: Object

Object

This built-in type serves as a hash table of string-any value pairs. It is also capable of holding native D objects. Objects may have a __proto__ field that is recursively searched when dictionary look ups fail. When an object is created from the new operator, the "prototype" field of the function becomes the __proto__ field of the created object, much like JavaScript.

Objects are created with the object expression: key value pairs separated by commas, with a colon between the key name and value expression, all within {} braces. Objects are also created with the new keyword combined with a function call to a constructor.

Methods

(static) assign(target, source) → {Object}

Assigns the source's own fields and properties to the target.
Parameters:
Name Type Description
target Object The object to store the properties and fields
source Object The object from which to assign.
Returns:
The now modified target
Type
Object

(static) create(object) → {Object}

Creates a new empty object whose __proto__ is the parameter.
Parameters:
Name Type Description
object Object The object to serve as the new object's __proto__
Returns:
A newly created object with the __proto__ set to the parameter.
Type
Object

(static) defineProperties(object, propDescriptions) → {Object}

Adds fields or properties to an object and returns it. This modifies the Object in place.
Parameters:
Name Type Description
object Object The object to modify.
propDescriptions Object An object containing keys whose values are objects containing either a value field, or get and/or set fields with Function values. If the get and set fields do not contain a Function, an error is thrown. Likewise, if propDescriptions' keys don't refer to an Object, an error is thrown.
Returns:
The modified Object
Type
Object

(static) defineProperty(object, propName, propData) → {Object}

Similar to defineProperties but only defines one field or property at a time. This modifies the Object in place.
Parameters:
Name Type Description
object Object The object to add the field or property to
propName String The name of the property
propData Object An Object containing a value, or get and/or set fields.
Returns:
The modified Object
Type
Object

(static) entries(object) → {Array.<Array>}

Get the key-value entries of an object
Parameters:
Name Type Description
object Object The object to get the key-value entries from
Returns:
An Array of length-2 Arrays whose first element is the key and second element associated value.
Type
Array.<Array>

(static) fromEntries(entries) → {Object}

Create a new Object from an Array of key-value Arrays.
Parameters:
Name Type Description
entries Array.<Array> An Array whose elements should be Arrays containing two values, the first element being a key, and the second the corresponding value
Returns:
A new Object created from the key value pairs.
Type
Object

(static) getOwnPropertyDescriptor(object, propName) → {Object}

Look for a specific property on the Object without searching the prototype chain.
Parameters:
Name Type Description
object Object The Object to search
propName String The name of the property
Returns:
an Object containing a possible get or set or value field, or an empty Object.
Type
Object

(static) getOwnPropertyDescriptors(object) → {Object}

Get all property and field descriptors from an Object.
Parameters:
Name Type Description
object Object An Object
Returns:
An Object containing keys for each field or property, whose values are an Object with a value, or get and/or set field.
Type
Object

(static) getOwnPropertyNames(object) → {Array.<String>}

Gets an Array of all property and field names. These values are unique.
Parameters:
Name Type Description
object Object An Object
Returns:
A list of unique property names.
Type
Array.<String>

(static) is(obj1, obj2) → {boolean}

Tests if two reference types refer to the exact same Object in memory.
Parameters:
Name Type Description
obj1 Object Any Object
obj2 Object Any Object
Returns:
True if the objects are referring to the same memory location, otherwise false.
Type
boolean

(static) keys(object) → {Array}

Return an array of all the keys in the specific object. Does not recursively search prototype chain.
Parameters:
Name Type Description
object Object The object whose keys to get
Returns:
An array of all string keys in no specific order
Type
Array

(static) setPrototypeOf(object, prototype) → {Object}

Sets the __proto__ of an Object and returns the Object
Parameters:
Name Type Description
object Object An Object whose __proto__ to set
prototype Object The new __proto__ of the Object
Returns:
The first parameter
Type
Object

(static) values(object) → {Array}

Returns an array of all values contained in an object. Does not recursively search prototype chain.
Parameters:
Name Type Description
object Object The object whose values to return
Returns:
An array of values in no specific order
Type
Array

hasOwnProperty(propName) → {boolean}

Tests if this Object has a given field or property without searching the prototype chain.
Parameters:
Name Type Description
propName String The name of the property
Returns:
True if this Object has the field or property, otherwise false.
Type
boolean

isPrototypeOf(object) → {boolean}

Tests whether or not this Object is the __proto__ of another Object
Parameters:
Name Type Description
object Object The Object whose __proto__ might be this Object
Returns:
True if this Object is the __proto__ of the parameter, otherwise false
Type
boolean

toString() → {String}

Returns a String representation of this Object. This method is available to all complex types that derive from Object, such as Array and Function.
Returns:
A String representation of this Object
Type
String