0

I am working on a project for a javascript program as seen in the following...

var temp = 14;
var y 2;
temp <<= y;
document.write(temp)

....and I can't figure out how the <<= operator works of how this program works. Can someone please explain how it works? Thanks.

  • 1
    [It's the left-shift assignment operator.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Assignment_operators) – Pointy Apr 04 '16 at 13:55
  • [What are bitwise operators](http://stackoverflow.com/questions/276706/what-are-bitwise-operators) – adeneo Apr 04 '16 at 13:58

1 Answers1

2

It is a bitwise left shift operator. For more details check here

a << b Shifts a in binary representation b (< 32) bits to the left, shifting in zeroes from the right.

Akshay Khandelwal
  • 1,570
  • 11
  • 19