Object

Moduleejs
Definitiondynamic class Object
StabilityEvolving.

The Object Class is the root class from which all objects are based.

It provides a foundation set of functions and properties which are available to all objects. It provides for: copying objects, evaluating equality of objects, providing information about base classes, serialization and deserialization and iteration.


Properties

QualifiersPropertyTypeDescription
public get lengthNumberThe length of the object. For Objects, length() will be set to the number of properties. For Arrays, it will be set to the the number of elements. Other types will set length to the most natural representation of the size or length of the object.

Object Methods

QualifiersMethod
public clone(deep: Boolean = true): Object
 Clone the object and all its elements.
iterator get(): Iterator
 Get an iterator for this object to be used by "for (v in obj)".
iterator getValues(): Iterator
 Get an iterator for this object to be used by "for each (v in obj)".
public toJSON(): String
 Convert an object to an equivalent JSON encoding.
public toString(): String
 This function converts an object to a string representation.

Method Detail

public clone(deep: Boolean = true): Object

Clone the object and all its elements.

Parameters
deep: Boolean If true, do a deep copy where all object references are also copied, and so on, recursively. A shallow clone will do 1 level deep. Deep clones are N-level deep. [default: true]
Specified
ejscript-1.1

iterator get(): Iterator

Get an iterator for this object to be used by "for (v in obj)".

Returns
An iterator object.
Specified
ejscript-1.1

iterator getValues(): Iterator

Get an iterator for this object to be used by "for each (v in obj)".

Returns
An iterator object.
Specified
ejscript-1.1

public toJSON(): String

Convert an object to an equivalent JSON encoding.

Returns
This function returns an object literal string.
Throws
TypeError: If the object could not be converted to a string.

public toString(): String

This function converts an object to a string representation.

Description
Types typically override this to provide the best string representation.
Returns
A string representation of the object. For Objects "[object className]" will be returned, where className is set to the name of the class on which the object was based.