Conversion method: 1. Use the String() function, the syntax "String(numbe)", to convert the parameter value into a string; 2. Use the toString() method, the syntax "number.toString()" ;3. Use " " operator, syntax "number ''".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
Method 1: Use the String() function
String(value): Force the parameter value to a string.
String(0); //返回字符串"0" String(1); //返回字符串"1"
Method 2: Use toString() method
var number = 5; number.toString();
method 3: Use the " " operator
and add an empty string
var number = 5; number + '';
javascript advanced tutorial 】
The above is the detailed content of How to convert numbers to characters in javascript. For more information, please follow other related articles on the PHP Chinese website!