Why does (0 < 5 < 3) return true? Why does (0 < 5 < 3) return true? javascript javascript

Why does (0 < 5 < 3) return true?


Order of operations causes (0 < 5 < 3) to be interpreted in javascript as ((0 < 5) < 3) which produces (true < 3) and true is counted as 1, causing it to return true.

This is also why (0 < 5 < 1) returns false, (0 < 5) returns true, which is interpreted as 1, resulting in (1 < 1).


My guess is because 0 < 5 is true, and true < 3 gets cast to 1 < 3 which is true.


probably because true is assumed as 1 so

0 < 5 < 3  -->  true < 3 -->  1 < 3  --> true