The Object Class : Object « Object Oriented « JavaScript Tutorial

Home
JavaScript Tutorial
1.Language Basics
2.Operators
3.Statement
4.Development
5.Number Data Type
6.String
7.Function
8.Global
9.Math
10.Form
11.Array
12.Date
13.Dialogs
14.Document
15.Event
16.Location
17.Navigator
18.Screen
19.Window
20.History
21.HTML Tags
22.Style
23.DOM Node
24.Drag Drop
25.Object Oriented
26.Regular Expressions
27.XML
28.GUI Components
29.Dojo toolkit
30.jQuery
31.Animation
32.MS JScript
JavaScript Tutorial » Object Oriented » Object 
25.2.1.The Object Class

The Object class in JavaScript is similar to java.lang.Object in Java.

The Object class in JavaScript is the base class for all JavaScript classes.

All the properties and methods of the Object class are also present in the other classes.

The Object class has the following properties:

  1. constructor -- For the Object class, this points to the native Object() function.
  2. prototype -- For the all classes, this returns an instance of Object by default.

The Object class also has several methods:

object.hasOwnProperty(property)

Determines if a given property exists for the object.

The property must be specified as a string.

For example, o.hasOwnProperty("name").

object.isPrototypeOf(object)

Determines if the object is a prototype of another object.

propertyIsEnumerable(property)

Determines if a given property can be enumerated by using the for...in statement.

object.toString()

Returns a primitive string representation of the object.

object.valueOf()

Returns the most appropriate primitive value of this object.

For many classes, this returns the same value as toString().

Each of the properties and methods listed previously are designed to be overridden by other classes.

25.2.Object
25.2.1.The Object Class
25.2.2.Object()
25.2.3.Object.constructor
25.2.4.Object.eval()
25.2.5.Object.prototype
25.2.6.Object.toSource()
25.2.7.Object.toString()
25.2.8.Object.unwatch()
25.2.9.Object.valueOf()
25.2.10.Object.watch()
25.2.11.Add method to Object class
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.