Why doesn't interval comparison bomb in JavaScript?
if(-1 < x < 1) {
console.log('x: ', x)
}
Why are we allowed to do this without getting errors?
Also it seems that:
-1 < x < 1
is true for x<=-1
1 < x < 1
is true for x<=1
-1 < x < -1
is always false
-2 < x < 2
is always true
In the last 2 cases it seems it is just comparing the 2 ends of the expressions. How are those expressions evalued?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…