This one says false, meaning the "" is a number:
alert(isNaN(""));
This one says NaN, meaning the "" is not a number and cannot be converted:
alert(parseFloat(""));
I was expecting the second code to convert "" to 0 since "" is a number when tested in IsNaN but I was wrong! Am I getting crazy or I just missed something?
parseFloattries to parse a number from string where asisNaNconverts the argument to number before checking it:Apparently this is “broken” or “confusing”, so from the specs: