What Is The Order Of Precedence For Boolean Operators In Js?
e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0) how would this expression evaluate?
Solution 1:
You can find a precedence table for Javascript operators on MDN: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Operator_Precedence. It is a great source for Javascript documentation in general.
Anyway, &&
has higher precedence than ||
so a && b || c || d
is equivalent to (((a && b) || c) || d)
. This is similar to many other language with a C-inspired syntax.
Post a Comment for "What Is The Order Of Precedence For Boolean Operators In Js?"