Conversion to a string (Definition)

Converting values to a string representation.

There are three conversions to study. Obviously string values will remain as they are.

This table summarizes the effects of converting values to strings:

Value:Resulting string:
Undefined value"undefined"
Negative infinity"-Infinity"
Numeric valueThat numeric value as a sequence of characters.
Boolean true"true"
Boolean false"false"
ObjectResult of Object.toString().
Object lacking a toString() method.Result of conversion of result from Object.valueOf() method.
Object without toString() or valueOf() methods.An error
ArrayComma elements joined by a comma.
FunctionDepends on implementation.

Converting objects to strings will first attempt to use the toString() method and then the valueOf() method, converting the resulting number to a string after that.