Home >Web Front-end >JS Tutorial >Introduction to the use of Javascript bitwise left shift operator (<<)_Basic knowledge
The bitwise left shift operator (<<)
Shifts the bits of an expression to the left.
result = expression1 << expression2
Parameter
result
Any variable.
expression1
Any expression.
expression2
Any expression.
Explanation
<< operator shifts all bits of expression1 to the left by the number of digits specified by expression2. For example:
var temp
temp = 14 << 2
The value of variable temp is 56, because 14 (that is, 00001110 in binary) shifted two places to the left equals 56 (that is, 00111000 in binary).
Javascript bitwise left shift operator (<<) converts the expression number into binary and then shifts the bits of the expression to the left.
result = [number to be shifted] << [number of shifts]
The bitwise left shift operator (<<) shifts the bits of [the number to be shifted] to the left by the number of digits specified in [number of bits to shift]. For example: