Home > Backend Development > PHP Tutorial > javascript - About operation priority

javascript - About operation priority

WBOY
Release: 2016-07-06 13:53:37
Original
921 people have browsed it

For
$a < $b || $c == $d && $e < $f

Can it be understood like this:
$a < $b || $c == $d;
At the same time
$c == $d && $e < $f;
And
$a < $b has no logical relationship with $e < $f?

Are the priorities in other languages ​​also used this way?

Reply content:

For
$a < $b || $c == $d && $e < $f

Can it be understood like this:
$a < $b || $c == $d;
At the same time
$c == $d && $e < $f;
And
$a < $b has no logical relationship with $e < $f?

Are the priorities in other languages ​​also used this way?

$a < $b || ($c == $d && $e < $f)

&& has higher priority than || .

Owner, please don’t take advantage of this. Writing like this is not allowed in team development.

Three logical operators from high to low: not and or

First of all, this way of writing is not recommended during development and will generally be killed.
1. This expression has comparison operators and logical operators, including logical operator && and logical operator ||.
For PHP, the comparison operator has a higher priority than the logical operators && and ||, but the logical operator && has a higher priority than the logical operator ||
javascript - About operation priority

$a < $b || $c == $d && $e < $f
So the result is like this: The first step is operator comparison: ($a<$b)| |($c==$d)&&($e<$f)
Compare || or &&
If ($a<$b) is true, then the expression result is Is true
If: ($a<$b) is fasle, and one of ($c==$d) and ($e<$f) is fasle, the result is false.

These are all experts...I never study this kind of problem, it’s very troublesome

<code>(($a < $b) || ($c == $d)) && ($e < $f)</code>
Copy after login

Isn’t this bad?

Do you promise not to look at this code again? Don’t you need to think when you watch it? So why bother yourself?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template