What is Bitwise NOT Operator (~) in JavaScript?

JavascriptWeb DevelopmentFront End Technology

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>
raja
Published on 19-Jan-2018 05:48:39
Advertisements