Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36 Edg/87.0.664.47
Chrome 87
Mac OS X 11.0.1
Desktop
4 years ago
Test name Executions per second
floor 3285475.0 Ops/sec
~~ 6032852.0 Ops/sec
>> 0 6032436.0 Ops/sec
| 0 6047907.0 Ops/sec
<< 0 6032501.5 Ops/sec
& 0xFFFFFFFFFFFF 6039361.5 Ops/sec
^ 0x000000000000 6030092.5 Ops/sec
Math.trunc() 3283493.5 Ops/sec
x - (x % 1) 4162351.8 Ops/sec
parseInt() 3313339.5 Ops/sec
Script Preparation code:
AخA
 
var x = Math.random() * 100000000;
var y;
Tests:
  • floor

     
    y = Math.floor(x);
  • ~~

     
    y = ~~x;
  • >> 0

     
    y = x >> 0;
  • | 0

     
    y = x | 0;
  • << 0

     
    y = x << 0;
  • & 0xFFFFFFFFFFFF

     
    y = x & 0xFFFFFFFFFFFF;
  • ^ 0x000000000000

     
    y = x ^ 0x000000000000;
  • Math.trunc()

     
    y = Math.trunc(x);
  • x - (x % 1)

     
    y = x - (x % 1);
  • parseInt()

     
    y = parseInt(x)