Flooring numbers in JavaScript: ~~n, n|0 or Math.floor(n)?
integer, javascript
Solution
Be clear to the next person looking at your code and use `Math.floor()`.
The performance gain of 1%-40% isn't really worth it, so don't make your code confusing and hard to maintain.
Problem
I've recently discovered some other ways to remove the fractional part of numeric values in JavaScript other than `Math.floor(n)`, specifically the double bitwise NOT operator `~~n` and performing a bitwise or with 0 `n|0`. I'd like to know what are the difference between these approaches and what the different scenarios are where one method is recommended over another.