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
-
AmyShackles709714dThat’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. -
CaptainRant442514d@AmyShackles Yes, my webdev skills are rusty. I'm slowly picking up on them again.
-
MM83123514dBeen 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.
-
MM83123514d@Lensflare that not a number is not not a number is one of the few immutable truths you can rely on with JS.
-
netikras3462614d@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
-
BordedDev218014d
-
MM83123513d@Lensflare perhaps we should lobby whichever chimp enclosure maintains the typescript spec to add the nNaN type, for clarity in these situations.
-
AlgoRythm5010213dJavaScript 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! -
AlgoRythm5010213d@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) -
MM83123513d@AlgoRythm is it 'blazing fast', though? I see a worrying lack of rocket emojis in that spiel.
-
AlgoRythm5010213d@MM83
🚀✨ Introducing isaN™: Because Knowing What IS a Number is the Future of AI-Driven, Cloud-Native, Disruption-As-A-Service™ ✨🚀
👨💻 Problem: Developers have been stuck in the dark ages with isNaN(), a function that can only tell you if something is not a number. But what if—💡—you actually wanted to know if something is a number? Until now, you were helpless. Enter isaN™, the hypermodern, zero-trust, blockchain-adjacent API that finally solves this billion-dollar pain point.
💾 Our patented NumCloud™ Verification Engine® leverages quantum-ready serverless edge functions 🛰️ to deliver instantaneous "YES, THAT IS A NUMBER ✅" responses at sub-millisecond latency (under ideal WiFi conditions, on Tuesdays).
📊 Pricing Tiers (confusing but investor-friendly):
🍼 Free (but not really): 10 calls/month, rate-limited to 1 call per fiscal quarter, requires filling out a 47-question compliance survey.
[Out of space for comment] -
AmyShackles709712dI resent that isNaN does not actually check if it’s a number before checking if it’s NaN.
But I also get that it’s TECHNICALLY accurate. If you pass something that’s not a number, it is IN FACT, not a number. But it’s not NaN (because it’s actually a string or object or whatever the fuck it is). It’s like the function is testing for something being not a number in the general sense and not testing for it not being a number in the specific sense. It’d almost be better if there was a stupid utility function for isNotANumber that behaved the way isNaN does and that isNaN only returned if something was, in fact, NaN.
It would have been a lot more straightforward if NaN was its own type.
typeof NaN
'number'
Yes... in JavaScript, the type of NaN is Number. Go figure...
rant
type
nan
javascript