Reputation: 2331
this is what´s happening
typeof Number.parseInt('processed')
prints 'number'
.
But if Number.parseInt('processed')
gives NaN
.
Upvotes: 1
Views: 422
Reputation: 10873
Number.parseInt('string')
returns NaN
, which has a type of number
.
You can verify it in the browser console:
typeof NaN === 'number'
true
Here's a handy guide on how to test against NaN
.
Upvotes: 9
Reputation:
NaN
is a value representing Not-A-Number.
Number.parseInt('processed')
is NaN
typeof NaN
is a number
.
The ECMAScript standard states that Numbers should be IEEE-754 floating point data. This includes Infinity
, -Infinity
, and also NaN
.
NaN < 1; // false
NaN > 1; // false
NaN == NaN; // false
Use Number.isNaN()
or isNaN()
to most clearly determine whether a value is NaN
.
Upvotes: 1