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
get constructorFunctionThe constructor function from which this object was created.
static get set prototypeObjectThe prototype object for objects of this type. The prototype object provides the template for instance properties shared by all objects of a given type.

Object Class Methods

QualifiersMethod
static create(prototype: Object, properties: Object = undefined): Object
 Create a new object, set the object prototype and properties.
static defineProperties(obj: Object, properties: Object): Void
 Define a set of properties on the given object.
static defineProperty(obj: Object, name: String, options: Object): Void
 Define or redefine a property on the given object.
static freeze(obj: Object): Void
 Freeze an object.
static getBaseType(obj: Type): Type
 Get the base type of a type object.
static getName(obj: Object): String
 Get the name of the object if it is a function or type.
static getOwnPropertyCount(obj: Object): Number
 The number of properties in the object including non-enumerable properties.
static getOwnPropertyDescriptor(obj: Object, prop: String): Object
 Get the prototype property descriptor.
static getOwnPropertyNames(obj: Object, options = null): Array
 Return an array of all property names including non-enumerable properties.
static getOwnPrototypeOf(obj: Object): Object
 Get the prototype object.
static getType(obj: Object): Type
 Get the type for an object.
static getTypeName(obj: Object): String
 Get the name of the type for an object.
static isExtensible(obj: Object): Boolean
 Test if an object is extensible.
static isFrozen(obj: Object): Boolean
 Test if an object is frozen.
static isPrototype(obj: Object): Boolean
 Test if the object is a prototype object.
static isSealed(obj: Object): Boolean
 Test if an object is sealed.
static isType(obj: Object): Boolean
 Test if the object is a type object.
static keys(obj: Object): Array
 Return an array of enumerable property names.
static preventExtensions(obj: Object): Object
 Prevent extensions to object.
static seal(obj: Object): Void
 Seal an object.

Object Instance Methods

QualifiersMethod
clone(deep: Boolean = true): Object
 Clone the object.
iterator get(options: Object = null): 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)".
hasOwnProperty(name: String): Boolean
 Check if an object has a property.
isPrototypeOf(obj: Object): Boolean
 Is this object a prototype of the nominated argument object.
propertyIsEnumerable(property: String): Boolean
 Test if the property is enumerable and visible in for/in traversals.
toJSON(): String
 Convert an object to an equivalent JSON encoded string.
toLocaleString(): String
 This function converts an object to a localized string representation.
toString(): String
 This function converts an object to a string representation.
valueOf(): String
 Return the value of the object.

Method Detail

clone(deep: Boolean = true): Object
Description
Clone the object.
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-2.7

static create(prototype: Object, properties: Object = undefined): Object
Description
Create a new object, set the object prototype and properties.
Parameters
prototype: Object Prototype object.
properties: Object Properties for the new object. [default: undefined]
Returns
The created object h.

static defineProperties(obj: Object, properties: Object): Void
Description
Define a set of properties on the given object.
Parameters
obj: Object Object on which to define the property.
properties: Object Hash of property descriptors X.

static defineProperty(obj: Object, name: String, options: Object): Void
Description
Define or redefine a property on the given object.
Parameters
obj: Object Object on which to define the property.
name: String Property name.
options: Object Property descriptor object. The descriptor has properties for: configurable, enumerable, get, namespace, set, value, and writable.
Options
configurableIf true, make the property configurable. This means it can be deleted and have its properties modified.
enumerableIf true, make the property visible to for/in enumerations.
getGetter function to return the property value.
namespaceProperty namespace qualifier.
setSetter function to update the property value.
valueInitial property value. Cannot use if a get or set property is defined.
writableIf true, the property value may be updated after the initial definition.

static freeze(obj: Object): Void
Description
Freeze an object. This freezes the object in its current configuration. It makes all properties readonly and thens seals the object preventing any properties from changing their configuration. It is useful as the ultimate lock-down for objects.
Parameters
obj: Object Object to freeze.

iterator get(options: Object = null): Iterator
Description
Get an iterator for this object to be used by "for (v in obj)".
Parameters
options: Object Iteration options. Reserved for future use. [default: null]
Returns
An iterator object.
Specified
ejscript-2.7

static getBaseType(obj: Type): Type
Description
Get the base type of a type object.
Returns
A type object.

static getName(obj: Object): String
Description
Get the name of the object if it is a function or type.
Returns
The string name of the function or type.

static getOwnPropertyCount(obj: Object): Number
Description
The number of properties in the object including non-enumerable properties.

static getOwnPropertyDescriptor(obj: Object, prop: String): Object
Description
Get the prototype property descriptor. This returns the property descriptor for the named property in the given object. Property names are interpreted using the set of currently open namespaces.
Parameters
obj: Object Object to inspect.
prop: String Property name.
Returns
The a property descriptor object. Return null if the property is not found.

static getOwnPropertyNames(obj: Object, options = null): Array
Description
Return an array of all property names including non-enumerable properties. This returns the bare names and does not include the namespace portions of the names. Use getOwnPropertyDescriptor to access property namespace values.
Parameters
obj: Object Object to inspect.
options Property selection options. [default: null]
Options
includeBasesBoolean determining if base class properties will included. Defaults to false.
excludeFunctionsBoolean determining if function properties will included. Defaults to false.
Returns
Array of enumerable property names.

static getOwnPrototypeOf(obj: Object): Object
Description
Get the prototype object.
Parameters
obj: Object Object to inspect.
Returns
The prototype object for the given object.

static getType(obj: Object): Type
Description
Get the type for an object. If the object is an instance, this is the class type object. If the object is a type, this value is Type.
Returns
A type object.

static getTypeName(obj: Object): String
Description
Get the name of the type for an object. If the object is an instance, this is the name of the class type object. If the object is a type, this value is "Type".
Returns
A type object.

iterator getValues(): Iterator
Description
Get an iterator for this object to be used by "for each (v in obj)".
Returns
An iterator object.
Specified
ejscript-2.7

hasOwnProperty(name: String): Boolean
Description
Check if an object has a property. The property names is interpreted using the set of currently open namespaces.
Parameters
name: String Name of property to check for.
Returns
True if the object contains the specified property.

static isExtensible(obj: Object): Boolean
Description
Test if an object is extensible.
Returns
True if the extensible trait of the object is true H.

static isFrozen(obj: Object): Boolean
Description
Test if an object is frozen.
Parameters
obj: Object Object to inspect.
Returns
True if the object is frozen.

static isPrototype(obj: Object): Boolean
Description
Test if the object is a prototype object.
Returns
True if the object is being used as a prototype object.

isPrototypeOf(obj: Object): Boolean
Description
Is this object a prototype of the nominated argument object.
Parameters
obj: Object Target object to use in test.
Returns
True if this is a prototype of obj. TODO - should be on the prototype chain - Need a prototype ns.

static isSealed(obj: Object): Boolean
Description
Test if an object is sealed.
Parameters
obj: Object Object to inspect.
Returns
True if the object is sealed.

static isType(obj: Object): Boolean
Description
Test if the object is a type object.
Returns
True if the object is a type object.

static keys(obj: Object): Array
Description
Return an array of enumerable property names.
Parameters
obj: Object Object to inspect.
Returns
Array of enumerable property names.

static preventExtensions(obj: Object): Object
Description
Prevent extensions to object. Sets the extensible property to false.
Returns
The object argument to permit chaining.

propertyIsEnumerable(property: String): Boolean
Description
Test if the property is enumerable and visible in for/in traversals. The property names is interpreted using the set of currently open namespaces.
Parameters
property: String Name of property to test.
Returns
True if this is a prototype of obj. TODO - prototype property H.

static seal(obj: Object): Void
Description
Seal an object. This prevents changing the configuration of any property. This includes preventing property deletion, changes to property descriptors or adding new properties to the object.
Parameters
obj: Object Object to seal.

toJSON(): String
Description
Convert an object to an equivalent JSON encoded string.
Returns
This function returns an object literal string.

toLocaleString(): String
Description
This function converts an object to a localized string representation. For many objects, this simply calls toString. If a class overrides, it may perform customized localization. For example: Date.toLocaleString will use the native O/S routines to encode localized dates.
Returns
A localized string representation of the object. 8.

toString(): String
Description
This function converts an object to a string representation. 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.

valueOf(): String
Description
Return the value of the object.
Returns
This object.