This internal operator converts its input argument to a string.
The ToString operator converts its input arguments according to the following table:
Input Type | Result |
---|---|
Undefined | "undefined" |
Null | "null" |
Boolean | If the argument is true, then the result is "true" otherwise the result is "false" |
Number | Special cases are provided for NaN and Infinity where "NaN" and "Infinity" will be returned. Otherwise the string is a textual representation of the value. The string is formatted into decimal or exponential formats as determined by the magnitude of the value. |
String | No conversion, the input value is returned unchanged. |
Object | An internal conversion to a primitive takes place followed by a conversion from that primitive to a string. Some objects will return a string value that is immediately useful. |
In Microsoft environments, this is available most of the time but does not work for certain objects. In particular, there may some objects in WSH for which it is not supported.
Prev | Home | Next |
ToPrimitive | Up | toString() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |