Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
typeof boolean vs === true || === false
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:141.0) Gecko/20100101 Firefox/141.0
Browser:
Firefox 141
Operating system:
Linux
Device Platform:
Desktop
Date tested:
7 months ago
Test name
Executions per second
typeof value === "boolean"
44538.9 Ops/sec
value === true || value === false
26335.4 Ops/sec
Script Preparation code:
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++; } }