Bitwise left-shift operator (<<)
The bit of the left-shift expression.
result = expression1 << expression2
Parameters
Result
Any variable.
Expression1
Any expression.
Expression2
Any expression.
Description
The << operator shifts all bits of the expression1 to the left expression2 the specified number of digits. For example:
var temp
temp = << 2
The value of the variable temp is 56 because 14 (that is, binary 00001110) shifts to the left two digits equals 56 (that is, binary 00111000).
The Javascript bitwise Left operator (<<) converts an expression number to binary, and then shifts the bits of the expression to the left.
result = "number to be shifted" << "number of displacement digits"
The bitwise Left operator (<<) shifts the bits of the "digits to be shifted" to the left by the number of digits specified in the offset digits. For example:
Copy Code code as follows:
var temp;
temp = << 2;
/*
14 of the binary is 00111000
00001110 left shift 2 bit 00111000 = 56
*/
Alert (temp);
Pop-up "56"