CodesJava

Easy learning with example program codes

javascript bitwise operators tutorial


JavaScript Bitwise Operators:

JavaScript bitwise operators are used to perform bitwise operations on the operands

JavaScript Bitwise Operators List:

Operator Description Example
& Bitwise AND (10==25 & 20==35) = false
| Bitwise OR (20==30 | 20==40) = false
^ Bitwise XOR (20==30 ^ 30==40) = false
~ Bitwise NOT (~20) = -20
<< Bitwise Left Shift (10<<2) = 40
>> Bitwise Right Shift (10>>2) = 2
>>> Bitwise Right Shift with Zero (10>>>2) = 2

JavaScript Bitwise Operators Example:

<html>
<head>
<script type="text/javascript">
            var a = 2; 
            var b = 3; 
            var linebreak = "<br />";
 
            document.write("(a & b) => ");
            result = (a & b);
            document.write(result);
            document.write(linebreak);
 
            document.write("(a | b) => ");
            result = (a | b);
            document.write(result);
            document.write(linebreak);
 
            document.write("(a ^ b) => ");
            result = (a ^ b);
            document.write(result);
            document.write(linebreak);
 
            document.write("(~b) => ");
            result = (~b);
            document.write(result);
            document.write(linebreak);
 
            document.write("(a << b) => ");
            result = (a << b);
            document.write(result);
            document.write(linebreak);
 
            document.write("(a >> b) => ");
            result = (a >> b);
            document.write(result);
            document.write(linebreak);
      </script>
</head>
   <body>
   </body>
</html>

Try it:

JS Bin on jsbin.com



Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki