3 ms·
JS gets even weirder when you include all the comparison operators. https://jsfiddle.net/5Yzs6/17/ https://jsfiddle.net/5Yzs6/17/ Did you know undefined is eq
by Kapow 10y ago
JS gets even weirder when you include all the comparison operators.
https://jsfiddle.net/5Yzs6/17/ https://jsfiddle.net/5Yzs6/17/
Did you know undefined is equal to undefined, but not <= undefined or >= undefined?
Or that two instances of the same object/array are not equal (e.g. [-1] != [-1]), but are both <= and >= each other?
Or that /.*/ is non-comparable (only != is true) to all numbers, but greater than [-0.5] and "-0.5", and less than [0] and "0"?
- andrepd 10y agoWhat a clusterfuck.
- twblalock 10y agoAnd yet, people say Brendan Eich doesn't believe in equality!
- AgentME 10y agoMost of the examples you point out make sense if you know that using greater than or less than casts the value to a number. >= and <= always cast their parameters to numbers while == only does if either side is already a number.
- __jal 10y agoIf you define "make sense" as "having an explanation not rooted in the supernatural", then yes. By that definition, Brainf*ck[1] also makes sense. [1]https://en.wikipedia.org/wiki/Brainfuck https://en.wikipedia.org/wiki/Brainfuck