(a==b==2)!=(a==2 && b==2)

来源:互联网 发布:js获取html class属性 编辑:程序博客网 时间:2024/04/25 16:21

Once I get value of variable a and variable b ,their value are both 2.And I want to judge whether they are equal.I make a mistake for using if(a==b==2).It is wrong.Because a==b is true and then the result compares to 2 will get false.(1!=2)
So I should write like this: if(a==2 && b==2).

0 0
原创粉丝点击