How to check if value is NaN in Typescript?
TypescriptTypescript Problem Overview
In TypeScript, how can we check if some value is NaN
?
The following does not work:
someObject.someValue == NaN
someObject.someValue === NaN
Typescript Solutions
Solution 1 - Typescript
Same as JavaScript, isNaN
.
if (isNaN(someObject.someValue)) ...
Or the more modern Number.isNaN
if (Number.isNaN(someObject.someValue)) ...