In JavaScript, the function that converts a number into the corresponding string is "toString()". toString() can convert a Number object into a string and return the result; the syntax format is "Number object.toString()".
The operating environment of this tutorial: Windows 7 system, ECMAScript version 5, Dell G3 computer.
In JavaScript, you can use the toString() function to convert a number into a corresponding string.
The toString() method converts a Number object into a string and returns the result.
Syntax
NumberObject.toString(radix)
Parameters:
radix: Optional. Specifies the base in which the number is represented, making it an integer between 2 and 36. If this parameter is omitted, base 10 is used. Note, however, that the ECMAScript standard allows implementations to return any value if the parameter is a value other than 10.
Return value:
The string representation of the number. For example, when radix is 2, the NumberObject is converted to a string representing the binary value.
Note: A TypeError exception is thrown when the object calling this method is not Number.
Example:
var number = new Number(1337); var str = number.toString() console.log(str); console.log(typeof str);
For more computer programming related knowledge, please visit: Programming Video! !
The above is the detailed content of What is the function in js that converts a number into the corresponding string?. For more information, please follow other related articles on the PHP Chinese website!