What is Bitwise NOT Operator (~) in JavaScript?



It is a unary operator and operates by reversing all the bits in the operand.

Example

You can try to run the following code to learn how to work with Bitwise NOT Operator(~) −

<html>
   <body>
      <script>
         var b = 3;   // Bit presentation 11

         document.write("(~b) => ");
         result = (~b);
         document.write(result);
      </script>
   </body>
</html>

Advertisements