Home  >  Article  >  Web Front-end  >  Summary of issues to note when converting js string to int_javascript skills

Summary of issues to note when converting js string to int_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:25:301071browse

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

Discover the number starting with format'00' in the parseInt method It will be converted as a binary to decimal method, so it is recommended to use the Number method to convert string to int.

Statement:
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