3 ms·
JS is poorly understood in comparison This might be the most hilariously ridiculous true statement I've ever heard.
by tenaciousDaniel 8y ago
JS is poorly understood in comparison
This might be the most hilariously ridiculous true statement I've ever heard.
- Tepix 8y agoIn 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 8y ago[deleted]
- bjoli 8y 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 8y 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 8y agoNitpick: NaN is supposed to work like that: the rule is that every comparison of any value against NaN returns false.
- sixothree 8y agoAt least x === x, right?
- dak1 8y agoconst x = NaN; x === x; // false
- SkyMarshal 8y 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
- joezydeco 8y agoBut they're close to getting two numbers to add together! https://twitter.com/thomasfuchs/status/933447631514169344 https://twitter.com/thomasfuchs/status/933447631514169344
- sandebert 8y agoThey should use jQuery for that. I hear it's good for all the things.