In Javascript
parseInt(null)
returns a NaN
parseNumber(null)
also returns a NaN
isNaN('abcd')
returns true
, as 'abcd' is of course not a number,
isNaN(5)
returns false
but strangely
isNaN(null)
returns false
, which is odd as implies it is a number, but as we saw in the parseNumber
it was seen by that as NaN
There appears to be an inconsistency between the way null is viewed by parseInt
and by isNaN
one sees it as NaN and the other sees it as a Number. Why are they inconsistent?