Javascript objects reference
Javascript build-in Object object reference.
Create objects:
To create an object: | new Object([param]) |
You uses the new keyword to create an object. | |
To use as a function: | Object([param]) |
When the Object object is used as a function the return will be an object as well. | |
param: | The param argument is optional. If it is absent an empty object is returned.
If the param argument is present, the result can be one of the following:
|
An example of using the new Object(param):
|
General information about the object member types:
- Prototype created methods, properties or constants can only be used on instances of an object or on a primitive datatype.
- Constructor created methods, properties or constants can NOT be used on instances of an object or on a primitive datatype.
Prototype Methods:
Syntax: | hasOwnProperty(propname) |
Objects can have its own local properties and properties inherited from its prototype object.
This method provides the ability to distinguish between the inherited properties and noninherited local properties. |
|
Return value: | true if the object contains 'propname' as its own local properties. false if the object does not contain 'propname' as a property or 'propname' is an inherited property. |
propname: | A string name of a property, as this method will be using in his test. |
An example of using the hasOwnProperty() :
|
Prototype Properties:
Syntax: | Object.prototype.constructor |
This property of the Object.prototype holds the reference back to the Object object. | |
Important note: | This is the same as the constructor property of an instantiated object |
Constructor (Object) Properties:
Syntax: | Object.constructor |
The constructor property is a reference to the function that will be invoked to create a Object object. |
© 2010 by Finnesand Data.
All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the
correctness in the pages or source codes.
The risk of using this web-site pages or any program
codes from this website is entirely at the individual user.