Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@bigus-dickus typeof NaN returns Number as string then why two string cannot pass equality check for type and value
-
@GAGANDEEPP @bigus-dickus typeof NaN returns 'number'. This statement should be true. But nobody stops you from defining the 'NaN' variable, just like nobody stops you to re-define 'undefined'.
For NaN, it's safer to use isNaN()
For undefined, it's safer to use void 0 -
@sunfishcc I meant, maybe use a language that compiles down to js so that you don't shoot yourself in the foot
Like Typescript, Elm, Purescript, etc. -
@RememberMe I use typescript with React. But not in NodeJs. Don’t like the extra generated code.
Typescript allows you to cast any as anything. So it doesn’t help if you try to format an arbitrary value as number. Test NaN is still required.
BTW, NaN is also in python. It’s part of the floating point system.
Related Rants
typeof NaN === typeof NaN //false
Why?
devrant
javascript
typeof
js