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
All Objects
Object Object
METHOD: Object::toString
Object.
toString
()
The
toString
method is inherited by every object descended from
Object
and returns a string representing a specified object. There are times when an object needs to be represented as a string, and the
toString
method (which comes with every object) is automatically called to do that.
ToString
returns the object type or the constructor function that created it. The following examples illustrate the use of this method and the return:
document.write(Sheeba)
returns
[object Object]
document.write(Sheeba.toString)
returns
function toString() { [native code] }
The
toString
method can, however, be overwritten in a custom object by assigning a user-defined function in its place as follows:
Code:
Cat.prototype.toString = myToString
NOTE:
Every core JavaScript object will over-ride the
toString
method to return an appropriate value, and will only call it when it needs to convert an object to a string.
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information