Table of contents
- 1. Summary
- 2. Syntax
- 3. Parameters
- 4. Description
- 5. Examples
- 6. See also
Summary
Returns a string representing the specified object.
Method of String | |
|---|---|
| Implemented in | JavaScript 1.1 |
| ECMAScript Edition | ECMAScript 1st Edition |
Syntax
string.toString()
Parameters
None.
Description
The String object overrides the toString method of the Object object; it does not inherit Object.toString. For String objects, the toString method returns a string representation of the object.
Examples
Example: Using toString
The following example displays the string value of a String object:
x = new String("Hello world");
alert(x.toString()) // Displays "Hello world"