parseInt('')
NaN
parseInt(null)
NaN
parseInt(undefined)
NaN
parseInt('asdfa')
NaN
parseInt('123')
123
parseInt('asd12')
NaN
// 转换后只保留前面数字
parseInt('1213ewer') 
1213
parseInt(false)
NaN

Number('')
0
Number(null)
0
Number(false)
0
Number(undefined)
NaN
Number('21a')
NaN

Number转换字符串直接比较大小
Number('1.2') > 1
true
Number('21a') > 1
false
Number('a21a') > 0
false

Number(-1)
-1
parseInt(-1)
-1

相关文章:

  • 2021-11-21
  • 2021-12-13
  • 2021-12-10
  • 2021-06-11
  • 2022-12-23
  • 2021-08-17
猜你喜欢
  • 2022-12-23
  • 2021-05-21
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案