isNaN() vs. parseInt() confusion

后端 未结 2 1133
深忆病人
深忆病人 2021-02-12 22:47

There is something strange.

Why
with isNaN(\"\") I get False
But
with parseInt(\"\") I get NaN
?

2条回答
  •  清酒与你
    2021-02-12 23:30

    isNaN takes an integer as an argument - therefore JS converts "" to 0

    parseInt takes a string as an argument - therefore an empty string is not a number

提交回复
热议问题