Here is the code:
alert(typeof(+"13t"));
alert(1 + (+"13t"));
Why in the first line the output is "number" And in the second line the output is "NaN"??
The value NaN
is a number. Even though NaN
means "not a number", it's still got the data type "number".
The string "13t"
when coerced to a number value yields NaN
, unsurprisingly. Adding 1
to NaN
also yields NaN
.