Home > Web Front-end > JS Tutorial > body text

Introduction to the use of bitwise 'XOR' operator in JavaScript_javascript tips

WBOY
Release: 2016-05-16 16:55:36
Original
1992 people have browsed it

The bitwise XOR operator (^) performs a bitwise XOR on two expressions. Usage:

Copy code The code is as follows:

result = expression1 ^ expression2

where result is any variable.
expression1 is any expression.
expression2 is any expression.

Bitwise XOR operator description
^ operator looks at the binary representation of the values ​​of two expressions and performs a bitwise XOR. The result of this operation is as follows:

0101 (expression1)
1100 (expression2)
----
1001 (result)

if and only if only When a bit of an expression is 1, the result will be 1. Otherwise this bit of the result is 0.
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