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
-
That’s why isNaN exists 😂
Though you have to check that it’s a number first or you end up with false positives if you’re dealing with things that can’t be coerced into being numbers. -
@AmyShackles Yes, my webdev skills are rusty. I'm slowly picking up on them again.
-
MM8312211dBeen a while but I always used to use (n == n), if that resolves to false then it's NaN. Not that this makes anything saner.
-
MM83122120h@Lensflare that not a number is not not a number is one of the few immutable truths you can rely on with JS.
-
netikras3457213h@MM83 wtf.. This begs for a util.js and an isNaN() inside. And whatever twisted magic it takes -- encapsulate it there, out of anyone's sight
-
BordedDev203410h
-
MM8312211h@Lensflare perhaps we should lobby whichever chimp enclosure maintains the typescript spec to add the nNaN type, for clarity in these situations.
-
AlgoRythm5002931mJavaScript getting heat for this is always so funny because it's a gateway drug to floating point encoding (which is a HELLSCAPE)
Surprise, here's the exact same thing in c (a function which returns NaN, which is a double)
Here's some homework for you: check out how infinity and negative infinity work too! -
AlgoRythm5002920m@MM83 @Lensflare introducing: isaN!
const isaN = num => !isNaN(num);
It will be available via NPM soon through a microservice that costs 2.99 a month and makes calls to
GET https://api.isan.io/v4/isan?n=x
Rate limited to 1000/day per key, of course, unless you purchase the enterprise subscription which costs $45 / seat / month and you're locked into a 2 year contract (the service will go out of business before your contract finishes)
typeof NaN
'number'
Yes... in JavaScript, the type of NaN is Number. Go figure...
rant
type
nan
javascript