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











METHOD:  Object::toSource Netscape Only Feature


Object.toSource()
 
The toSource method returns a literal representing the source code of an object. This can then be used to create a new object. Although the toSource method is usually called by JavaScript behind the scenes, you can call it yourself. In the case of the built-in Object object, it returns a string indicating that the source code is not available, while, for instances of Object, it returns the source. With a user-defined object, toSource will return the JavaScript source that defines it. The following examples illustrate these three cases:
 
Code:
Object.toSource()
 
Output:
function Object() { [native code] }
 
Code:
function Cat(breed, name, age)
{
   this.breed = breed
   this.name = name
   this.age = age
}
Cat.toSource()

 
Output:
function Cat(breed, name, age) { this.breed = breed; this.name = name; this.age = age; }
 
Code:
Sheeba = new Cat("Manx", "Felix", 7)
Sheeba.toSource()

 
Output:
{breed:"Manx", name:"Felix", age:7}

 


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