javascript - Why does isNaN(" ") equal false -
I have a quick question (I hope!). In JS, why do isNaN ("") wrong, but evaluate to isNa ("x") correct?
I am performing numeric actions on the text input field, and checking that the field is empty, "", or NaN, when a person finds a handful of spaces in the area, then my The validation fails in all three, and I am confused about why this isNAN has been investigated.
Thank you!
Javascript interprets an empty string as a 0, which then fails in the ISNAN test is. You can use parseInt on the string which will not convert an empty string to 0. The result should be unsuccessful. NAN
Comments
Post a Comment