- JavaScript Basics
- JavaScript Home
- JavaScript Syntax
- JavaScript Placements
- JavaScript Output
- JavaScript Statements
- JavaScript Keywords
- JavaScript Comments
- JavaScript Variables
- JavaScript var
- JavaScript let
- JavaScript const
- JavaScript var Vs let Vs const
- JavaScript Operators
- JavaScript Arithmetic Operators
- JavaScript Assignment Operators
- JS Comparison Operators
- JavaScript Logical Operators
- JavaScript Bitwise Operators
- JavaScript Ternary Operator
- JavaScript Operator Precedence
- JavaScript Data Types
- JavaScript typeof Operator
- JS Conditional Statements
- JavaScript Conditional Statement
- JavaScript if Statement
- JavaScript if...else Statement
- JavaScript switch Statement
- JavaScript Loops
- JavaScript for Loop
- JavaScript while Loop
- JavaScript do...while Loop
- JavaScript break Statement
- JavaScript continue Statement
- JavaScript break Vs. continue
- JavaScript Popup Boxes
- JavaScript Dialog Box
- JavaScript alert Box
- JavaScript confirm Box
- JavaScript prompt Box
- JavaScript Functions
- JavaScript Functions
- JS Function with Parameter
- JavaScript Return Statement
- JavaScript Variable Scope
- JavaScript setTimeout() Method
- JavaScript setInterval() Method
- JavaScript Events
- JavaScript Events
- JavaScript onclick Event
- JavaScript onload Event
- JavaScript Mouse Events
- JavaScript onreset Event
- JavaScript onsubmit Event
- JavaScript Objects
- JavaScript Objects
- JavaScript Number Object
- JavaScript Array Object
- JavaScript String Object
- JavaScript Boolean Object
- JavaScript Math Object
- JavaScript RegExp Object
- JavaScript Date Object
- JavaScript Browser Objects
- JavaScript Browser Objects
- JavaScript Window Object
- JavaScript Navigator Object
- JavaScript History Object
- JavaScript Screen Object
- JavaScript Location Object
- JavaScript Document Object
- JS Document Object Collection
- JS Document Object Properties
- JS Document Object Methods
- JS Document Object with Forms
- JavaScript DOM
- JavaScript DOM
- JavaScript DOM Nodes
- JavaScript DOM Levels
- JavaScript DOM Interfaces
- JavaScript Cookies
- JavaScript Cookies
- JavaScript Create/Delete Cookies
- JavaScript Advance
- JavaScript Regular Expression
- JavaScript Page Redirection
- JavaScript Form Validation
- JavaScript Validations
- JavaScript Error Handling
- JavaScript Exception Handling
- JavaScript try-catch throw finally
- JavaScript onerror Event
- JavaScript Multimedia
- JavaScript Animation
- JavaScript Image Map
- JavaScript Debugging
- JavaScript Browser Detection
- JavaScript Security
- JavaScript Misc
- JavaScript innerHTML
- JavaScript getElementById()
- JS getElementsByClassName()
- JS getElementsByName()
- JS getElementsByTagName()
- JavaScript querySelector()
- JavaScript querySelectorAll()
- JavaScript document.write()
- JavaScript console.log()
- JavaScript instanceof
- JavaScript Programs
- JavaScript Programs
- JavaScript Test
- JavaScript Online Test
- Give Online Test
- All Test List
Bitwise Operators in JavaScript
Bitwise operators in JavaScript are used to perform bitwise (bit-wise or bit-by-bit) operations. For example:
HTML with JavaScript Code
<!DOCTYPE html> <html> <body> <script> let x = 6, y = 3; document.write(x & y); </script> </body> </html>
Output
Note - Bit operators works on 32-bits number. Bitwise operations goes on bit patterns (binary numerals), involves individual bits manipulation.
In above example, the binary equivalent of 6 is 110 (or 0000 0000 0000 0000 0000 0000 0000 0110 in 32-bit number). Whereas the binary equivalent of 3 is 11 (or 0000 0000 0000 0000 0000 0000 0000 0011 in 32-bit number). Therefore:
1 1 0 & 0 1 1 ---------- 0 1 0
The 010 or 10 is equal to 2 in decimal. That is, in 32-bit numbers:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 (6) & 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 (3) ----------------------------------------------------------------------- 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 (2)
List of All Bitwise Operators in JavaScript
- Bitwise AND (&)
- Bitwise OR (|)
- Bitwise XOR (^)
- Bitwise NOT (˜)
- Bitwise Right Shift (>>)
- Bitwise Left Shift (<<)
- Bitwise Unsigned Right Shift (>>>)
To learn about Bitwise operators with example in detail, refer to its separate tutorial.
« Previous Tutorial Next Tutorial »