We all know that there are two methods to convert a value into a string. One is to use the tostring () method, and the other is to use the transformation function string (). However, some details are worth noting.
1. Almost every value has the tostring () method, which indicates that some values do not exist, that is, null and undefined.
2. You can use tostring () to return a copy of the string.
3. The tostring () method can pass a parameter, indicating the base number of the value.
For example, var t = 8;
T. tostring (2); // 1000
The default value is 10. It should be noted that the tostring () parameter set for non-numeric values (Boolean, String, etc.) is invalid,
For example, var t = "8 ";
T. tostring (2); // 8, which may be considered as 1000
4. You can use the string () method for any value. The process is as follows:
First, if the value has the tostring () method, use this method (No parameter ).
Second, there is no tostring () method for this value, that is, null returns "null", undefined returns "undefined"