JS comparison


#1

x = 10;
y = 5;
alert(x > y);

Why does it not alert “10 > 5” but “true” ?


#2

because the comparison is resolved first, the result of comparison is then displayed in an alert message

to achieve what you want, use a string (with variable if you want)