Script Preparation code:
AخA
 
var values = Array.from({length: 10000}, (_, i) => i % 5 === 0 ? i % 3 === 0 : i % 2 ? i.toString() : i);
Tests:
  • typeof value === "boolean"

     
    let bools = 0;
    for (let i = 0; i < values.length; i++) {
      const value = values[i];
      if (typeof value === "boolean") {
        bools++;
      }
    }
  • value === true || value === false

     
    let bools = 0;
    for (let i = 0; i < values.length; i++) {
      const value = values[i];
      if (value === true || value === false) {
        bools++;
      }
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    typeof value === "boolean"
    value === true || value === false

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0
Firefox 83 on Ubuntu
View result in a separate tab
Test name Executions per second
typeof value === "boolean" 23981.9 Ops/sec
value === true || value === false 9623.1 Ops/sec