ToString (Operator/internal)

Return a string primitive version of an object.


ECMAScript edition - 2

This internal operator converts its input argument to a string.

The ToString operator converts its input arguments according to the following table:

Input TypeResult
BooleanIf the argument is true, then the result is "true" otherwise the result is "false"
NumberSpecial 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.
StringNo conversion, the input value is returned unchanged.
ObjectAn 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.


See also:Cast operator, Conversion, Implicit conversion, JSObject.toString(), String concatenate (+), toString(), Type conversion


ECMA 262 edition 2 - section - 9.8

ECMA 262 edition 3 - section - 9.8