Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0
Firefox 136
Linux
Desktop
one month ago
Test name Executions per second
Math.abs 293203.2 Ops/sec
Two equals, negative first 279960.8 Ops/sec
Two equals, positive first 278194.3 Ops/sec
Script Preparation code:
AخA
 
const thenumber = -90
Tests:
  • Math.abs

     
    if (Math.abs(thenumber) === 90) { console.log(thenumber) }
  • Two equals, negative first

     
    if (thenumber === -90 || thenumber === 90) { console.log(thenumber) }
  • Two equals, positive first

     
    if (thenumber === 90 || thenumber === -90) { console.log(thenumber) }