I mean, NaN implies there exists some value, it’s just not a numerical one. null days there is none at all.
There are different kinds of non-number “values” for numeric variables. Is this ∞, Overflow, NaN or N/A?
luciferofastora@feddit.org 21 hours ago
getFrog@piefed.social 23 hours ago
I’m a JavaScript girl, I only know about null and undefined. But my guess would be
N/A, just by method of elimination?∞: They said the N-word, but if we ask “did they say the N-word yesterday?” and go back a day if the answer is no, we will be iterating forever.Overflow: They said the N-word sometime before Jan 1st 1970.NaN: Days since the last time they said the N-word: “yes”BlackRoseAmongThorns@slrpnk.net 21 hours ago
All these special values are from the spec for floating point numbers, integers don’t have them, in JS specifically all numbers are floats.
An
Option<int>does a good of showing intent.ChaoticNeutralCzech@feddit.org 22 hours ago
There are actually two interpretations of
N/A:N/A(not available): There is lost media so it can’t be evaluated.N/A(not applicable): The show is in sign language so evaluating that is outside the scope of this string-matching program.Meanwhile,
undefinedseems to mean the value has not yet been evaluated. Maybenullis really the best.elephantium@lemmy.world 15 hours ago
🎵 I’m a Java girl in a Java world…
Sadly, JavaScript breaks the cadence :(
NikkiDimes@lemmy.world 18 hours ago
Whaaat Javascript is famously known for being extremely weird with NaN values lol
humorlessrepost@lemmy.world 14 hours ago
Yeah but we almost never use them intentionally. In almost any project, NaN only happens if there’s a bug. The others are regularly on purpose.
NikkiDimes@lemmy.world 11 hours ago
People use NaN on purpose? 😨😨😨