JavaScript-About Operation Precedence

Source: Internet
Author: User
For
$a < $b | | $c = = $d && $e < $f

Is it possible to understand this:
$a < $b | | $c = = $d;
While
$c = = $d && $e < $f;
And
$a < $b have no logical relationship with $e < $f?

Is the priority of other languages so used?

Reply content:

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

Is it possible to understand this:
$a < $b | | $c = = $d;
While
$c = = $d && $e < $f;
And
$a < $b have no logical relationship with $e < $f?

Is the priority of other languages so used?

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

&& priority is higher than | | 。

Lou Zhu do not drill this corner. In team development, this is not Xu Yun written.

Three logical operators from high to Low: not and OR

First of all, this type of writing is not recommended during development, and will generally be killed.
1. This expression has comparison operators and logical operators, where logical operators && and logical operators | |.
For PHP, comparison operators have precedence over logical operators && and | |, but logical operators && precedence over logical operators | |

$a < $b | | $c = = $d && $e < $f
So the result of the operation is this: the first step is the operator comparison: ($a < $b) | | ($c = = $d) && ($e < $f)
Comparison of operators after comparison | | or &&
if ($a < $b) is true, the result of this expression is true
if: ($a < $b) is Fasle and ($c = = $d) and ($e < $f) One of them is fasle, the result is false.

This is a tall man ... I never study this kind of problem, it's very troublesome.

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

Isn't that good?

Do you promise not to read this code again? Don't you need to think when you look at yourself? Then why do you make trouble for yourself?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.