How to check if value is NaN in Typescript?

Typescript

Typescript 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)) ...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionajaysinghdav10dView Question on Stackoverflow
Solution 1 - TypescriptzehView Answer on Stackoverflow