JavaScript is smart enough to know that the first
two terms are tied together via the &&
Expression evaluation in programming languages is not an AI or
guessing process ;-) Everything is strictly defined in what is called
"Operator Precedence Table". The only way to break this precedence is
by using parenthesis. && stays by precedence way below ! and != so
grouping parenthesis are needed.
JavaScript operator precedence table consists of 15 positions; I'm
jumping on a chance to post it in full - because however important
this table is many people are not aware of it.
15 positions, from the highest priority to the lowest one:
1) . [] ()
Property accessor, array indexing, function calls, and expression
grouping
2) ++ -- - ~ ! delete new typeof void
Unary operators, return data type, object creation, undefined values
3) * / %
Multiplication, division, modulo division
4) + - +
Addition, subtraction, string concatenation
5) << >> >>>
Bit shifting
6) < <= > >= instanceof
Less than, less than or equal, greater than, greater than or equal,
instanceof
7) == != === !==
Equality, inequality, strict equality, and strict inequality
8) &
Bitwise AND
9) ^
Bitwise XOR
10) |
Bitwise OR
11) &&
Logical AND
12) ||
Logical OR
13) ?:
Ternary conditional
14) =
Assignment
15) ,
Comma (multiple evaluation)