Use the shift left operator in JavaScript
Description
The following code shows how to use the shift left operator.
Example
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
<!--from w w w . ja va2 s . co m-->
// 2 = 00000000000000000000000000000010
// 8 = 00000000000000000000000000001000
var x = 2 << 2;
document.write("2 << 2 = ",x);
</script>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Bitwise
Use Bitwise Exclusive OR Operator in JavaSc...
Use Bitwise NOT (~) Operator in JavaScript
Use Compound Bitwise OR Assignment |= in Ja...
Use Shift Left Assignment operator in JavaS...
Use Shift Right Zero Fill Assignment Operat...
Use Shift Right Zero Fill Operator in JavaS...
Use Shift Right with Sign Assignment Operat...
Use Shift Right with Sign operator in JavaS...
Use the Bitwise AND Operator in JavaScript
Use the Bitwise AND Plus Assignment Operato...
Use the Bitwise Exclusive OR Operator in Ja...
Use the Compound Bitwise AND Operator in Ja...
Use Bitwise Exclusive OR Operator in JavaSc...
Use Bitwise NOT (~) Operator in JavaScript
Use Compound Bitwise OR Assignment |= in Ja...
Use Shift Left Assignment operator in JavaS...
Use Shift Right Zero Fill Assignment Operat...
Use Shift Right Zero Fill Operator in JavaS...
Use Shift Right with Sign Assignment Operat...
Use Shift Right with Sign operator in JavaS...
Use the Bitwise AND Operator in JavaScript
Use the Bitwise AND Plus Assignment Operato...
Use the Bitwise Exclusive OR Operator in Ja...
Use the Compound Bitwise AND Operator in Ja...