Object
Module | ejs |
Definition | dynamic class Object |
Stability | Evolving. |
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
Qualifiers | Property | Type | Description |
---|---|---|---|
get | constructor | Function | The constructor function from which this object was created. |
static get set | prototype | Object | The 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
Qualifiers | Method |
---|---|
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
Qualifiers | Method |
---|---|
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
- 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
- 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
configurable If true, make the property configurable. This means it can be deleted and have its properties modified. enumerable If true, make the property visible to for/in enumerations. get Getter function to return the property value. namespace Property namespace qualifier. set Setter function to update the property value. value Initial property value. Cannot use if a get or set property is defined. writable If true, the property value may be updated after the initial definition.
- 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.
- 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
- Description
- Get the base type of a type object.
- Returns
- A type object.
- Description
- Get the name of the object if it is a function or type.
- Returns
- The string name of the function or type.
- Description
- The number of properties in the object including non-enumerable properties.
- 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.
- Returns
- The a property descriptor object. Return null if the property is not found.
- 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
includeBases Boolean determining if base class properties will included. Defaults to false. excludeFunctions Boolean determining if function properties will included. Defaults to false.
- Returns
- Array of enumerable property names.
- Description
- Get the prototype object.
- Parameters
obj: Object Object to inspect.
- Returns
- The prototype object for the given object.
- 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.
- 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
- 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.
- Description
- Test if an object is extensible.
- Returns
- True if the extensible trait of the object is true H.
- Description
- Test if an object is frozen.
- Parameters
obj: Object Object to inspect.
- Returns
- True if the object is frozen.
- Description
- Test if the object is a prototype object.
- Returns
- True if the object is being used as a prototype object.
- 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.
- Description
- Test if an object is sealed.
- Parameters
obj: Object Object to inspect.
- Returns
- True if the object is sealed.
- Description
- Test if the object is a type object.
- Returns
- True if the object is a type object.
- Description
- Return an array of enumerable property names.
- Parameters
obj: Object Object to inspect.
- Returns
- Array of enumerable property names.
- Description
- Prevent extensions to object. Sets the extensible property to false.
- Returns
- The object argument to permit chaining.
- 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.
- 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.