1

Simple JS question: 10 > 9 > 8 === true; returns false.

Can somebody please elaborate and explain?

Thanks in advance!

theusual
  • 741
  • 2
  • 11
  • 24

1 Answers1

15

Please find answer Below:

10 > 9 > 8 === true;

The > operator has a higher precedence than === and is left-to-right associative. If we add the implicit parentheses we get this:

((10 > 9) > 8) === true;

This evaluates further to:

((10 > 9) > 8) === true;
(true > 8) === true;
(1 > 8) === true;
false === true;
false;
kiran malvi
  • 1,058
  • 10
  • 21