Use Shift Left Assignment operator in JavaScript

Description

The following code shows how to use Shift Left Assignment operator.

Example


<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
<!--from   w w w  . j a  v a  2 s  . com-->
//  3 = 00000000000000000000000000000011
// 12 = 00000000000000000000000000001100
x = 3;
x <<= 2;
document.write("x = ",x);
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Use Shift Left Assignment operator in JavaScript