Ad

JavaScript Bitwise Operators

 

JavaScript Bitwise Operators

Bitwise Operators

1]  AND  ( & )

2] OR ( | )

3] NOT ( ~ )

4] XOR ( ^)

6] right shift ( >>)

5] left  shift ( << )

Example :-

Bitwise Operators Example :

Bitwise Operators


1]  AND  ( & )

Example :-


// Bitwise AND (&)
 let q = 5;
 let p = 3
 let resultAnd= q & p;
 console.log("q&p", resultAnd);

Output :-

Bitwise And


2] OR ( | )

Example :-


// Bitwise Or (|)  
 let q = 5;
 let p = 4;
 let resultor= q | p;
 console.log("q|p", resultor);

Output :-



3] NOT ( ~ )

Example :-

// Bitwise not (~ )
 let q = 4;
 
 let resultNotq= ~ q ;
 console.log("~q", resultNotq);
Output :-



4] XOR ( ^)

Example :-


let x=5;
let y=1;
let result = x ^ y;
console.log(result);

Output :-



6] right shift ( >>)

Example :-


let x=6;
let result =x<<1;
console.log(result);

Output :-



5] left  shift ( << )

Example :-


let x=2;
let result =x>>1;
console.log(result);

Output :-

No comments

Powered by Blogger.