JavaScript << Left shift Operator
The left shift operator (<<) moves the bits of an integer to the left, which multiplies it by a power of two.
Description
The left shift operator << shifts the bits of the left operand (as a 32-bit integer) left by the given number of places, filling with zeros. Shifting by n multiplies by 2n, as long as the result fits in 32 bits.
Shifting is a fast way to build bit masks, as in 1 << n to set bit n. Only the lowest five bits of the shift count are used, so shifting by 32 is the same as shifting by 0. Because results are 32-bit signed integers, shifting a 1 into the top bit produces a negative number, as 1 << 31 shows.
For multiplication by powers of two in ordinary code, * or ** are clearer and don't have the 32-bit limit. BigInts can be shifted too, with no size limit, as long as both operands are BigInts.
Properties
- Operator
<<- Category
- Bitwise
- Precedence
- 10 (1 is lowest, 18 is highest)
- Associativity
- left-to-right
Syntax
x << yExample
Browser Support
The following information will show you the current browser support for the << operator. Hover over a browser icon to see the version that first introduced support for this operator.
Desktop





Tablets & Mobile





