-5

Possible Duplicate:
What do these operators do?
What is this expression in Java ( 1 << 2)?

What does >> and << operators in JavaScript do?

I've never seen them before and im breaking my head trying to understand them.

Any help is appreciated :D

Community
  • 1
  • 1
Tom
  • 1,217
  • 3
  • 12
  • 15
  • 9
    https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators?redirectlocale=en-US&redirectslug=Core_JavaScript_1.5_Reference%2FOperators%2FBitwise_Operators – PeeHaa Sep 07 '12 at 23:16
  • 1
    trying to find the javascript question that this is a dupe of, if only it wasn't so hard to search for on [SO] – zzzzBov Sep 07 '12 at 23:18
  • 2
    To address this sort of question about a language, please consult a reference. The keyword is, of course, **operators**. -1 because you knew *what* look for. –  Sep 07 '12 at 23:19
  • Don't forget `>>>`, `-->`, `-->>`, `-->>>`, `<--` and `<<--`. – some Sep 07 '12 at 23:30

3 Answers3

0

They are bit shifting operators.

Mozilla Reference 1

Mozilla Reference 2

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
0

They are bitwise shift operators.

In practice they are used to shift bits of variables by the specified amount, eg

2 << 2 = 8
Jack
  • 131,802
  • 30
  • 241
  • 343
0

They are standard bitwise shift operators. You need to draw 1 and 0s on paper to understand it better:

https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Expressions_and_Operators

Andrei Drynov
  • 8,362
  • 6
  • 39
  • 39