Home > Web Front-end > JS Tutorial > body text

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

烟雨青岚
Release: 2020-07-15 13:08:36
forward
3471 people have browsed it

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()
Copy after login

(2)

var   x=100;   
a   =   x   +"";     //JS会自动隐性转换  
javascript   将string 变成 int
JScript 
var s = "32" 
var i = new Number(s)
parseInt()
parseInt()
Copy after login

For example:

parseInt("abc") // Returns NaN. 
parseInt("12abc") // Returns 12. 
parseInt("12") //Return 12. 
<script></script>
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!