How to convert int type into string type in javascript
(1)
var x=100 a = x.toString()
(2)
var x=100; a = x +""; //JS会自动隐性转换 javascript 将string 变成 int JScript var s = "32" var i = new Number(s) parseInt() parseInt()
For example:
parseInt("abc") // Returns NaN. parseInt("12abc") // Returns 12. parseInt("12") //Return 12. <script></script>
Thank you for reading, I hope you will benefit from it.
Recommended tutorial: "JS Tutorial"
The above is the detailed content of Learn about the conversion of int and string in JS in one minute (with code). For more information, please follow other related articles on the PHP Chinese website!