Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36
Chrome 88
Mac OS X 11.1.0
Desktop
4 years ago
Test name Executions per second
floor 3233256.2 Ops/sec
~~ 6363912.5 Ops/sec
>> 0 6621987.0 Ops/sec
| 0 6643276.0 Ops/sec
<< 0 6615749.0 Ops/sec
& 0xFFFFFFFFFFFF 6631967.0 Ops/sec
^ 0x000000000000 6652741.0 Ops/sec
Math.trunc() 3167428.2 Ops/sec
x - (x % 1) 3992902.0 Ops/sec
parseInt() 2941514.0 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)