1

I stumbled upon this for the first time, what does the ~~n mean in JavaScript?

var isSquare = function(n) {
   n = Math.sqrt(n);
   return n == ~~n;
}

I know that the code checks if n is a "perfect" square.

Bryant James
  • 1,284
  • 2
  • 12
  • 36
userden
  • 1,441
  • 4
  • 24
  • 45
  • See this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators (bitwise not) – sodawillow Dec 29 '16 at 19:31

0 Answers0