this post was submitted on 17 May 2025
502 points (97.9% liked)
Programmer Humor
23522 readers
1761 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Option C. The value
NaN
compares unequal to every value, even itself. This breaks one of the rules of what equality even means (that every value must be equal to itself, the "reflexivity" axiom). It is for this reason (among others, ~~equality~~ "partial" equivalence between values of different types? 🤮) Rust needed to havePartialEq
. See IEEE 754 for more details.Why
typeof null
is"object"
? Because it is defined so: https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-typeof-operatorAs for the rationale behind the choice, it might have something to do with "Prototypal inherience" the language has. https://tc39.es/ecma262/multipage/overview.html#sec-objects
We can understand this to mean that prototype chains are
null
terminated ;)For example:
Uhh...
Now, let's go to some abstract algebra. All good (closed) binary operations we deal with have an identity or neutral value. For example: addition has 0, multiplication has 1, boolean
and
hastrue
, booleanor
orxor
hasfalse
. Performing these operations with the neutral value does not change the other operand: for example,x + 0 == x
,a * 1 == a
,true && b == b
and so on. If you admitmin
andmax
as operators, you can see why ∞ and -∞ are the neutral values, respectively:min(∞, x) == x
andmax(-∞, y) == y
for every (real) value of x and y. Observe howArray.prototype.reduce
works (with its second argument) for inspiration on why and how all this matters: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceFor mathematicians: closed, because the operators are maps
S × S →S
, to exclude<
,>
etc. as they map toBool
. Oh, they are relations, bla bla .... real numbers, we don't want to deal with other total orders here, there should be some way to call orders that have both top and bottom values, complex numbers don't have orders (usual ones, are there unusual ones?), bla bla blaAs for the last one, sigh.. https://tc39.es/ecma262/multipage/abstract-operations.html#sec-islooselyequal
Oh, that
!
s in there aren't booleannot
.. they are.. (looks it up) argh, read it yourself https://tc39.es/ecma262/multipage/notational-conventions.html#sec-returnifabrupt-shorthandsMe, wasting my time explaining an ECMAScript meme.. I be like, I need to somehow justify the time spent learning about all of these.. it was the language I started my programming journey with.. sigh