39 ms·
In javascript: x == x _ is true. Good. x == !x _ is also true. Oops? And guess what: Array(3)==",," _ is also true. But NaN == NaN _ is false. Math.ma
by Tepix 9y ago
In javascript:
x == x _ is true. Good.
x == !x _ is also true. Oops?
And guess what:
Array(3)==",," _ is also true.
But
NaN == NaN _ is false.
Math.max()>Math.min() _ is also false!
but then again
Math.max()<Math.min() _ is true.
Madness, I tell you!
- deleted 9y ago[deleted]
- bjoli 9y agoI just looked at the famous left-pad for the fastest way o implementing a pad function in JS. I asked a friend that does web dev and it is apparently pretty idiomatic JS. Pretty appalling. I finally understood why people claimed it was "hard to get right".
- scott_s 9y agoNaN not being equal to itself is true in all languages with IEEE compliance: https://en.wikipedia.org/wiki/NaN https://en.wikipedia.org/wiki/NaN
- conistonwater 9y agoNitpick: NaN is supposed to work like that: the rule is that every comparison of any value against NaN returns false.
- sixothree 9y agoAt least x === x, right?
- dak1 9y agoconst x = NaN; x === x; // false
- SkyMarshal 9y ago:D Many more Javascript WTF's here: https://www.youtube.com/results?search_query=javascript+wtf https://www.youtube.com/results?search_query=javascript+wtf