Re:A one-second video taken by the Rosetta probe on the surf...
by Tepix on Wednesday April 25, 2018 @08:14AM
(#16920774)
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!
Re:A one-second video taken by the Rosetta probe on the surf...
by scott_s on Wednesday April 25, 2018 @10:14AM
(#16921670)
NaN not being equal to itself is true in all languages with IEEE compliance: https://en.wikipedia.org/wiki/NaN
Re:A one-second video taken by the Rosetta probe on the surf...
by conistonwater on Wednesday April 25, 2018 @10:58AM
(#16922072)
Nitpick: NaN is supposed to work like that: the rule is that every comparison of any value against NaN returns false.
Re:A one-second video taken by the Rosetta probe on the surf...
by bjoli on Wednesday April 25, 2018 @08:47AM
(#16920995)
I 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".
Re:A one-second video taken by the Rosetta probe on the surf...
by SkyMarshal on Wednesday April 25, 2018 @10:44PM
(#16928397)
:D Many more Javascript WTF's here: https://www.youtube.com/results?search_query=javascript+wtf
Re:A one-second video taken by the Rosetta probe on the surf...
by sixothree on Wednesday April 25, 2018 @11:32AM
(#16922456)
At least x === x, right?
Re:A one-second video taken by the Rosetta probe on the surf...
by dak1 on Wednesday April 25, 2018 @01:00PM
(#16923562)
const x = NaN;
x === x; // false
This might be the most hilariously ridiculous true statement I've ever heard.