+ 1
If * (multiplication) has higher precedence than /(Division) then why alert is not 1.
Alert(2×2÷2×2);
3 Antworten
+ 4
in javascript (and most of languages) multiplication has same precedence than division, so left to right associativity occurs ^^
to do multiplication before division, use parenthesis ;P
+ 2
The expression is evaluated from left to right like this
2 * 2 -> (4)
(4) / 2 -> (2)
(2) * 2 -> (4)