integer - Flooring numbers in JavaScript: ~~n, n|0 or Math.floor(n)? -
i've discovered other ways remove fractional part of numeric values in javascript other math.floor(n), double bitwise not operator ~~n , performing bitwise or 0 n|0.
i'd know difference between these approaches , different scenarios 1 method recommended on another.
be clear next person looking @ code , use math.floor().
the performance gain of 1%-40% isn't worth it, don't make code confusing , hard maintain.
Comments
Post a Comment