What is it?
~x == -(x + 1)
So ~(10) will give you -11. There's another caveat to the ~ operator. It casts floating point numbers to integers by dropping everything after the decimal. So in the more general sense,
~x == -(Math.trunc(x) + 1)
Recall that Math.trunc() is kind of like Math.floor(), except the value (positive or negative) will always be rounded towards 0. The ~~ technique is a common trick you'll find a lot of developers using. Let's resolve it:
~~x = -(Math.trunc(-(Math.trunc(x) + 1)) + 1)
= -(Math.trunc(-(Math.trunc(x)) - 1) + 1)
= -(Math.trunc(-(Math.trunc(x))) + 1 - 1)
Essentially, ~~ is used as a short-hand hack for Math.trunc().
But you should probably never use it.
Instead of using ~~ just stick with Math.floor(). If you want a way to truncate decimals (flooring both positive and negative numbers towards 0), add this declaration at the top of your code: