Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the bitwise operators of JavaScript

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "what are the bitwise operators of JavaScript". Friends who are interested may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what the bitwise operators of JavaScript are.

JavaScript is described by bitwise operator name & bitwise and if both bits are 1, each bit is set to 1 | Bitwise or if one of the two bits is 1, each bit is set to 1 ^ different by bit or if only one of the two bits is 1, each bit is set to 1 ~ does not reverse all bits arithmetic right to move to the right by pushing a copy of the leftmost bit from the left And make the rightmost bit fall off > zero fill move right by pushing zero from the left to the right, and let the rightmost bit fall off.

Example:

Operation result equivalent result 5 & 110101 & 000100015 | 150101 | 00010101 ~ 510010110105 120101 > > 100105 > > 120101 > > 10010 bitwise and

When performing bitwise and operations on a pair of bits, 1 is returned if both bits are 1.

An example of operation:

The result of the operation is 000.It returns 00001.It returns 01000.It returns 01001.It returns 1 bit or 1.

When performing a bitwise or operation on a pair of bits, 1 is returned if at least one of the bits is 1, otherwise 0 is returned:

An example of operation:

Operation result 0 | 0 returns 00 | 1 returns 11 | 0 returns 11 | 1 returns 1

You can try it online.

Bitwise XOR

When performing a bitwise XOR operation on a pair of bits, if the bits are different (or), 1 is returned:

An example of operation:

Operation result 0 ^ 0 returns 00 ^ 1 returns 11 ^ 0 returns 11 ^ 1 returns 1

More comprehensive advanced applications of JavaScript operators

At this point, I believe you have a deeper understanding of "what are the bitwise operators of JavaScript?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report