DEV Community

Discussion on: TIPS & TRICKS OF JAVASCRIPT & REACT

Collapse
val_baca profile image
Valentin Baca

For Tip #5, the ~~ trick is more like Math.trunc rather than Math.floor

See the behavior on negative numbers:

Math.floor(-2.2)
-3
Math.trunc(-2.2)
-2
~~(-2.2)
-2
Enter fullscreen mode Exit fullscreen mode

Some comments have been hidden by the post's author - find out more