logical operators in JS &&, | |, bitwise OPERATORS |,&

Source: Internet
Author: User
Tags bitwise operators logical operators

1, js in the | | Symbol:

Method of Operation:

As long as "| |" False in front, regardless of "| |" Followed by true or FALSE, return "| |" The value that follows.

As long as "| |" Preceded by true, regardless of "| |" Followed by true or FALSE, return "| |" The preceding value.

Summary: After the true pre-leave

2, JS in the && symbol:

Method of Operation:

As long as "&&" is preceded by false, whether "&&" is followed by true or false, the result will be returned to the value preceding "&&";

As long as "&&" is preceded by true, whether "&&" is followed by true or false, the result will be returned to the value after "&&";

Summary: Fake before really after

Understand the above said should also know:

JS 6 eggs: In the JS logic operation, 0, "", null, False, undefined, Nan will be sentenced to false, the other is true.

Give me a chestnut:

3, bitwise operators: |

Method of Operation:

Two bits as long as there is a 1, then the result is 1. Otherwise, it would be 0.

Continue to raise chestnuts

| Operators can also perform rounding operations

4, bitwise operator:&

Method of Operation:

The number of two digits is the same as, at the same time, 1 is 1, as long as a 0 is 0.

or raise chestnuts:

logical operators in JS &&, | |, bitwise OPERATORS |,&

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.