What is Bitwise Left Shift Operator (<<) in JavaScript?

JavascriptWeb DevelopmentFront End Technology

The left shift operator moves all the bits in its first operand to the left by the number of places specified in the second operand. New bits are filled with zeros.Shifting a value left by one position is equivalent to multiplying it by 2, shifting two positions is equivalent to multiplying by 4, and so on.


You can try to run the following code to learn how to work with Bitwise Left Shift Operator −

         var a = 2; // Bit presentation 10
         var b = 3; // Bit presentation 11

         document.write("(a << b) => ");
         result =(a << b);
Published on 19-Jan-2018 05:47:09