toString()
Object
instance method getterS2C Home
« Globals « Object « toString()
Description
Returns a string of the specified object.
- Automatically invoked when an object is called and a string is expected or when viewing the object as a string.
- The
Object.toString()
method is inherited by allObject
descendants. - Unless overridden by a custom object
toString()
returns[object Object]
.
Syntax
Signature | Description |
---|---|
anObject.toString() | Returns a string of the specified object. |
Parameters
None.
Examples
The code below creates an object and displays it.
// Create an object.
anObject = new Object();
alert(anObject.toString() + ' anObject is an Object instance.');
Related Tutorials
JavaScript Basic Tutorials - Lesson 7 - Objects