JavaScript Kit > JavaScript Reference > Here
Object object
You can define your own objects in JavaScript, with custom properties and methods.
Constructor:
var myobject=new Object()
var myobject={ } //object literal. Supported in JavaScript 1.2
Related Tutorials
Properties
| Properties | Description |
|---|---|
| constructor | Specifies the function that's the constructor for the object. |
Methods
| Methods | Description |
|---|---|
| hasOwnProperty(prop) | Returns true if an object has a
property with the name as indicated by the parameter prop.
Returns false if the property doesn't exist or is
inherited from the prototype chain versus a direct property of the
object.var dog=new Object() |
| isPrototypeOf(o) | Returns true if one object is the
prototype of another . Use this method to detect
the class of an object (o).Example 1: var fruits=["apple",
"grapes"] Example 2: function Car(){ |
| propertyIsEnumerable(prop) | Returns true if the entered property
name of this object is enumerable using
for...in
Returns false if either property doesn't exist, or if
the object inherited the property from the prototype object. All
user defined properties to an object are enumerable, while in
general, built in properties/methods are not.
var mycar=new Object() |
| toString() | A method that's typically called implicitly by
JavaScript whenever you call an object within the context in which a
string value is expected, such as alerting an object:
alert(mycar). By default it returns the object in the string
representation [object Type].A common task for programmers to do is to override this method with something more robust, especially for custom objects. the default returned value is less than descriptive of the object. For example: function records(){
|
| valueOf() | A method that's typically called implicitly by JavaScript whenever you call an object within the context in which a primitive value is expected. Rarely if ever called explicitly. |
- JavaScript Operators
- JavaScript Statements
- Global functions
- Escape Sequences
- Reserved Words
- Anchor
- Applet
- Area
- Array
- Boolean
- Date
- Document
- Event
- Form
- Reset
- Frame
- Function
- History
- Image
- Link
- Location
- Math
- Navigator
- Number
- Object
- RegExp
- Screen
- String
- Style
- window

