What does ~~ do in JavaScript/node.js?

javascript, node.js

Solution

The `~` operator flips the bits of its operand. Using it twice flips the bits, then flips them again, returning a standard Javascript value equivalent to the operand, but in integer form. It's shorthand for `parseInt(myInt)`.

Problem

Possible Duplicate: What is the “double tilde” (~~) operator in JavaScript? I found this snip of code in a node.js library's source. What effect does `~~` have on the `input` variable? ``` inArray[3] = ~~input; ``` It's also used in other ways: ``` return ~~ ((a - b) / 864e5 / 7 + 1.5); ```

Original source

Related problems