What does << mean in Javascript
This question already has an answer here:
It's the bitwise left shift operator. The operands are converted to 32-bit integers, the left operand's bits are shifted left by the number of positions defined by the right operand, and the expression's value is the result.
Here's a simple example:
var a = 1;
var b = a << 2; // Move the bit left by two places
console.log(b); // "4"
That works because in a signed 32-bit integer, 1
looks like this in binary:
00000001
If you move that bit to the left two places:
00000100
...you get 4
.
上一篇: <<是什么意思在JavaScript中
下一篇: <<什么意思在Javascript中