The expression
0.5 < 0.6 < 0.7
is evaluated, like this
(0.5 < 0.6) < 0.7
Since the first part is true
, it will be effectively
true < 0.7
Both the sides will be tried to be converted to a number and since true
is 1
when converted to a number, the expression becomes
1 < 0.7
which is not correct. That is why false
is returned.
Same way, in the second case,
1.5 < 1.6
is true
, so it becomes 1
and the expression becomes
1 < 1.7
which is true
.
You can check the behaviour of booleans as numbers, like this
console.log(+true);
// 1
console.log(+false);
// 0
console.log(Number(true));
// 1
console.log(Number(false));
// 0