Asked • 03/19/19

Which Logic Operator Takes Precedence?

So, I'm looking into writing a slightly more complex operation with logic operators in an if-else statement. I know I can do parentheses, and I know it's the better way of doing this, but I've gotten curious and so I'm going to ask. If I were to do something like this: if (firstRun == true || selectedCategory != undefined && selectedState != undefined) { //Do something } else { //Do something else } How will that be operated without the use of parentheses? I know there is an order of operations for logic operators, similar to PEMDAS, right? I'm curious if it'll be ran something like this: firstRun == true || (selectedCategory != undefined && selectedState != undefined) or maybe if the 'OR' operator takes precedence instead and it ends up going like: (firstRun == true || selectedCategory != undefined) && selectedState != undefined The full list would be nice, if you can find it somewhere, of the order of operations for this. Thanks!

1 Expert Answer


Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.