Home >Web Front-end >JS Tutorial >js data toString method_basic knowledge
toString method
returns the string representation of the object.
objectname.toString([radix]) parameters
objectname
Required. To get the object represented by a string.
radix
Optional. Specifies the base when converting numeric values to strings.
Description
The toString method is a member of all built-in JScript objects. Its operation depends on the type of object:
Object operation
Array Converts the elements of Array to strings. The resulting strings are comma separated and concatenated.
Boolean If the Boolean value is true, return "true". Otherwise, return "false".
Date returns the text representation of the date.
Error Returns a string containing relevant error information.
Function returns a string in the following format, where functionname is the name of the called toString method function:
function functionname( ) { [native code] }
Number returns the text representation of the number.
String returns the value of the String object.
The default returns "[object objectname]", where objectname is the name of the object type.
Example
The following example demonstrates using the toString method with a radix parameter. The return value of the function shown above is a Radix conversion table.