⊗jsPmCdLOP 115 of 502 menu

Precedence of logical operators in JavaScript

The operation && takes precedence over ||. In the following example, the condition will be true if the variable num is between 0 and 5 OR between 10 and 20:

let num = 3; if (num > 0 && num < 5 || num > 10 && num < 20) { console.log('+++'); } else { console.log('---'); }

Explain how the comparison is performed under the following condition:

if (num == 0 || num > 1 && num < 5 ) { console.log('+++'); } else { console.log('---'); }
enru