Back to the lesson

The result of OR AND OR

importance: 5

What will be the result?

alert( null || 2 && 3 || 4 );

The answer: 3.

alert( null || 2 && 3 || 4 );

The precedence of AND && is higher than ||, so it executes first.

The result of 2 && 3 = 3, so the expression becomes:

null || 3 || 4

Now the result if the first truthy value: 3.