This is so deep that I had to revaluate how I make life decisions.

I've had quite a few of those moments with JavaScript.

  • 0
    @No-one I use ~ quite a lot with indexOf. I discovered a few years ago and was mind blown.
  • 2
    @No-one instead of doing arr.indexOf(something) > 0 you do ~arr.indexOf(something), because it inverts the indecies. Instead of 0, 1, 2... You get -1, -2, -3...
  • 2
    Shorter explanation of what @No-one said is that the tilde "~" operator inverts all the bits of a number.
Add Comment