Home > Web Front-end > JS Tutorial > JavaScript uses Number method to convert string to int_javascript technique

JavaScript uses Number method to convert string to int_javascript technique

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:48:34
Original
1559 people have browsed it
Copy code The code is as follows:

var str='1250' ;

alert( Number(str) ); //Get 1250

alert(parseInt(str)); //Get 1250

var str1='00100';

alert( Number (str1) ); //Get 100

alert(parseInt(str1)); //Get 64

It is found that the parseInt method will be used as a number starting with format'00' Convert binary to decimal, so it is recommended to use the Number method to convert string to int.
Related labels:
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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template