Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project











PROPERTY:  Object::constructor


Object.constructor
 

 
A constructor property is inherited by all objects from their prototype. It is this fact that allows you to create a new instance of an object using the new operator. If you display the constructor property of any object, you see the construction of the function that created it.
 
For example, assuming the existence of an object called 'Cat', the following code would display that function:
 
Code:
document.write(Cat.constructor)
 
Output:
function Cat(breed, name, age) { this.breed = breed this.name = name
this.age = age }

 
The constructor property can also be used to compare two objects (including those, such as documents and forms, that cannot be constructed). This next example compares the 'Sheeba' object with the 'Cat' object to see if it is an instance of it:
 
Code:
if(Sheeba.constructor == Cat)
   document.write("This is an instance of 'Cat'.")

 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information