JavaScript bitwise operators

Source: Internet
Author: User

Not

bitwise non, symbol is wavy line ~

function bar all bits of the binary number are non-operational, the corresponding decimal result is a negative value for the original 10 binary number and minus 1

Other operators feel less common, bitwise AND (&), bitwise OR (|), left (<<), Shift Right (>>), unsigned Right shift (>>>)

XOR (^), wherein the 10 binary number can be considered when the left to move, right to move with caution, symbolic problems

---------------------------------------------------------------------------------------------------------------

Logical operators:

and

and operation, symbol for &&

That is true when both are true and the rest is false.

This can be written when you use the properties of an object in general.

obj&&obj.attr;

Indicates that the obj.attr is executed if obj exists

FN&&FN ();

The general callback function likes to write like this

Or

Or, as long as one is true, the symbol | |

Setting default values can be used this way

var a=x| | 1;

If x is not defined, it is the default value

JavaScript 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.