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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -