Why do chained comparison operators seem to work as "OR"?

This may be something without a short answer. But I just ran up against this fact:
2 < 6 < 4 -> true
I know I can work around it by saying 2 < 6 && 6 < 4, but now I’m curious about why it works that way.
This seems as if these two evaluations are “short-circuiting” as if with an OR between them, like 2 < 6 || 6 < 4. Is there an easy answer to why JS does this?

I don’t think it’s short circuting as an OR

2 < 6 > 4    // returns false 

if it’s short-circuiting, it would have return true…

Don’t know why.

I think what ends up happening is that the operation runs from left to right.

It evaluates the first part 2 < 6 as true

true is coerced into 1 in the second statement, so 1 < 4 evaluates as true

2 < 6 < 1 will return false

1 Like

But wait, how do you explain @owel’s example?

2 < 6 -> true
6 > 4 -> true
2 < 6 > 4 -> false
1 Like

Doesnt make sense. See my example above

2 < 6 > 4

1 < 6 is true
6 > 4 is true
AND YET…
2 < 6 > 4 is false!

Because 1 > 4 is false

Okay, here we go: http://stackoverflow.com/questions/4089284/why-does-0-5-3-return-true/