Re:JavaScript: The Curious Case of null >= 0
by justinpombrio on Thursday September 14, 2017 @11:46PM
(#15254474)
Oh interesting. The triple I found used the same general idea of values that sometimes coerce to a number, but it made use of octal values instead of Infinity.
x = ''
y = '-Infinity'
z = -1
x < y // true: '-Infinity' (y) doesn't get coerced into a number, so '' < 'any string with at least 1 character'
y < z // true: '-Infinity' (y) compares with a number, so it coerces to -Infinity, which is less than -1 (z)
z < x // true: '' (x) is compared with a number, so it coerces to 0, which is greater than -1 (z)
Thank you for the brain exercise!
P.S. - No one ever use crap like this in production code!