JavaScript Bitwise Operators
Bitwise Operators
1] AND ( & )
2] OR ( | )
3] NOT ( ~ )
4] XOR ( ^)
6] right shift ( >>)
5] left shift ( << )
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 (&)
let q = 5;
let p = 3
let resultAnd= q & p;
console.log("q&p", resultAnd);
2] OR ( | )
Example :-
// Bitwise Or (|) let q = 5; let p = 4; let resultor= q | p; console.log("q|p", resultor);
Output :-
// Bitwise Or (|)
let q = 5;
let p = 4;
let resultor= q | p;
console.log("q|p", resultor);
3] NOT ( ~ )
Example :-
// Bitwise not (~ ) let q = 4; let resultNotq= ~ q ; console.log("~q", resultNotq);Output :-
// Bitwise not (~ )
let q = 4;
let resultNotq= ~ q ;
console.log("~q", resultNotq);
4] XOR ( ^)
6] right shift ( >>)
5] left shift ( << )
Example :-
let x=2;let result =x>>1;console.log(result);
Output :-
let x=2;
let result =x>>1;
console.log(result);
Post a Comment