parseInt

原生js函数

官方文档:http://www.w3school.com.cn/js/jsref_parseInt.asp

实例应用:

document.write(parseInt('',10)+'<br/>');//NaN

document.write(Boolean( parseInt('',10) )+'<br/>');//false

document.write(parseInt('0.5',10)+'<br/>');//0

document.write(Boolean( parseInt('-1.5',10) )+'<br/>');//false

document.write(Boolean( parseInt('-0.5',10) )+'<br/>');//false

document.write(parseInt('2.59hg',10)+'<br/>');//2

document.write(parseInt('-2.59hg',10)+'<br/>');//-2

document.write(parseInt('g2.59hg',10)+'<br/>');//NaN
原文地址:https://www.cnblogs.com/longze/p/2844646.html