Home  >  Article  >  Web Front-end  >  Learn about the conversion of int and string in JS in one minute (with code)

Learn about the conversion of int and string in JS in one minute (with code)

烟雨青岚
烟雨青岚forward
2020-07-15 13:08:363482browse

Learn about the conversion of int and string in JS in one minute (with code)

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete