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.toString
METHOD: Object::valueOf
Object.
valueOf
()
The
valueOf
method returns a primitive value for a specified object and is inherited by all objects descended from
Object
. It is usually called automatically by JavaScript behind the scenes whenever it encounters an object where a primitive value is expected. If the object has no primitive value, then the object itself is returned as [object Object]. You can also call
valueOf
yourself to convert a built-in object into a primitive value. The following two examples illustrate uses of it:
Code:
(Object.valueOf()
Output:
function Object() { [native code] }
Code:
function Cat(breed, name, age)
{
this.breed = breed
this.name = name
}
Cat.valueOf()
Output:
function Cat(breed, name, age) { this.breed = breed this.name = name }
The
valueOf
method can also be overwritten in a custom object by assigning a user-defined function with no arguments in its place as follows:
Code:
Cat.prototype.valueOf() = myValueOf()
NOTE:
Every core JavaScript object will over-ride the
valueOf
method to return an appropriate value.
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information