Object | NN 3 IE 4 ECMA 1 | |||||
In addition to serving quietly as the foundation of all native JavaScript objects, the Object object is the pure model of the JavaScript object including custom scripts objects you create. Use the Object object to generate things in your scripts with behaviors that are defined by custom properties and/or methods. Most typically, you start by creating a blank object with the constructor function and then assign values to new properties of that object. |
||||||
Navigator 4 and later and IE 5 and later also let you assign properties and values via a special literal syntax that also creates the Object instance in the process: var myObject = {propName1:propValue1[, propName2:propValue2[, ...propNameN:propValueN]]} |
||||||
You can use objects as data structures for structured custom data in your scripts, much like creating an array with named index values. |
||||||
Properties | ||||||
|
||||||
Methods | ||||||
|
||||||
Creating an Object Object | ||||||
var myObject = new Object( ); var myObject = {propName1:propVal1[, propName2:propVal2[,...N]]}; var myObject = new constructorFuncName([propVal1[, propVal2[,...N]]]); |
constructor | NN 4 IE 4 ECMA 1 |
Read/Write | |
Provides a reference to the function that created the instance of an Object objectthe native Object( ) constructor function in browsers. |
|
Example | |
if (myVar.constructor == Object) { // process native string } |
|
Value | |
Function object reference. |
prototype | NN 4 IE 4 ECMA 1 |
Read/Write | |
This is a property of the static Object. Use the prototype property to assign new properties and methods to future instances of an Object created in the current document. See the Array.prototype property description for examples. |
|
Example | |
Object.prototype.author = "DG"; |
|
Value | |
Any data, including function references. |
hasOwnProperty( ) | NN 6 IE 5.5(Win) ECMA 3 |
hasOwnProperty("propertyName") | |
Returns Boolean true if, at the time the current object's instance was created, its constructor (or literal assignment) contained a property with a name that matches the parameter value. A property assigned to an object via its prototype property is not considered one of the object's own properties. |
|
Parameters | |
|
|
Returned Value | |
Boolean value: true | false. |
isPrototypeOf( ) | NN 6 IE 5.5(Win) ECMA 3 |
isPrototypeOf(objectReference) | |
Returns Boolean true if the current object and the object passed as a parameter coincide at some point along each object's prototype inheritance chain. Note that IE and Navigator do not always agree on the results. |
|
Parameters | |
|
|
Returned Value | |
Boolean value: true | false. |
propertyIsEnumerable( ) | NN 6 IE 5.5(Win) ECMA 3 |
propertyIsEnumerable("propertyName") | |
Returns Boolean true if the property, whose name is passed as a parameter, exposes itself to for/in property inspection through the object. |
|
Parameters | |
|
|
Returned Value | |
Boolean value: true | false. |
toLocaleString( ) | NN 6 IE 5.5(Win) ECMA 3 |
Browsers are free to determine how to localize string representations of object instances. For now, they appear to perform the same action as the toString( ) method, returning the value [object Object]. |
|
Parameters | |
None. |
|
Returned Value | |
String. |
toString( ) | NN 4 IE 4 ECMA 1 |
Returns the object's value as a string data type. In recent browsers, this value is [object Object]. |
|
Parameters | |
None. |
|
Returned Value | |
String. |
valueOf( ) | NN 4 IE 4 ECMA 1 |
Returns the object's value. |
|
Parameters | |
None. |
|
Returned Value | |
An object reference. |