1

I've seen a single | being used in code somewhere but I have no idea what it means. I know that || is 'or'.

I typed it in the console and these are my results:

1 | 0 // 1
0 | 1 // 1
1 | 2 // 3
2 | 4 // 6

Does | just add the two numbers? Or is there more?

user1823
  • 1,111
  • 6
  • 19
wonghenry
  • 575
  • 2
  • 6
  • 18

1 Answers1

1

You're on the right way - the single pipe in JavaScript stands for a bitwise or. You can find the documentation here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#.7c_%28Bitwise_OR%29

Stephan Weinhold
  • 1,623
  • 1
  • 28
  • 37