I'm just so confused right now. If NaN = NaN and sqrt(-1) = NaN, why doesn't sqrt(-1) = sqrt(-1)?

It because the this NaN is different from this Nan is different from this NaN . The first two are not actually text: , , while the last one is: . In the first cases, NaN stands for "Not a Number", meaning that the result is undefined and not even a number. However, they are not considered equal by snap as they could represent different "not a numbers".

Not just Snap*!*, which is written in JavaScript, which uses the IEEE floating-point standard*, which specifies certain criteria of bits to represent NaN and NaN is never equal to any other value (even itself or other NaN values).

*That's the official website, but other sources (e.g. GeeksforGeeks) probably explain it better.