Tom Lehman
Tom Lehman

Reputation: 89233

Why is 5 > 4 > 3 != (5 > 4 && 4 > 3) true in Javascript?

Why is 5 > 4 > 3 != (5 > 4 && 4 > 3) true in Javascript?

So annoying!

Upvotes: 5

Views: 550

Answers (2)

cambraca
cambraca

Reputation: 27835

5 > 4 > 3 is evaluated like (5 > 4) > 3, then it's true > 3, which is false. Look

Upvotes: 17

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798716

JavaScript, in the great tradition of most languages that descend from C, does not support relational operator chaining.

Upvotes: 6

Related Questions