0

I was going through a small program and i came across this syntax in javascript.

hash = Math.abs((hash << 2) ^ (hash + y))

please what does it mean?

hash was initially 0; i.e hash = 0;

Nina Scholz
  • 376,160
  • 25
  • 347
  • 392
  • no more context? – Mister Jojo Mar 19 '20 at 20:52
  • 1
    `<<` is a bitwise operator: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Left_shift. `hash << 2` is equivalent to the math operation of `hash * Math.pow(2, 2)` – Terry Mar 19 '20 at 20:55
  • 1
    [`<<` - bitwise shift left](https://stackoverflow.com/questions/4535328/what-do-these-javascript-bitwise-operators-do) [`^` - bitwise XOR](https://stackoverflow.com/questions/3618340/javascript-what-does-the-caret-operator-do). And `+` is addition, `Math.abs` is absolute value. – VLAZ Mar 19 '20 at 21:01
  • thanks. It really helped – adefuye abayomi Mar 20 '20 at 21:41

0 Answers0