Reputation: 137
console.log(10 > 9 < 8);
When I print this, I get the value true
Why is this so? Could someone please explain along with some documentation, if possible.
Upvotes: 1
Views: 123
Reputation: 382122
10 > 9 < 8
is
(10 > 9) <8
(because comparison operators are left-associative)
which is
true < 8
where true
is casted (using ToNumber) to a number, 1
(details here)
Upvotes: 11
Reputation: 2163
10 > 9 => is true
then true < 8 is true because true will be evaluated to 1
Upvotes: 6