floor vs ~~ vs >> 0 vs | 0 vs << 0 vs Math.trunc() vs x - (x % 1) vs parseInt() vs round()| Test case name | Result |
|---|---|
| floor | |
| ~~ | |
| >> 0 | |
| | 0 | |
| << 0 | |
| Math.trunc() | |
| x - (x % 1) | |
| parseInt() | |
| round() |
| Test name | Executions per second |
|---|---|
| ✓ << 0 | 560,085 Ops/sec |
| Math.trunc() | 556,840 Ops/sec |
| round() | 547,389 Ops/sec |
| >> 0 | 544,900 Ops/sec |
| parseInt() | 543,337 Ops/sec |
| | 0 | 527,917 Ops/sec |
| ~~ | 523,947 Ops/sec |
| floor | 476,565 Ops/sec |
| x - (x % 1) | 464,062 Ops/sec |