Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
typeof undefined vs falsey/truthy
which is faster
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser:
Chrome 129
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
!!val
10.3M/s
!val
10.0M/s
typeof val !== 'undefined'
9.9M/s
typeof val === 'undefined'
9.7M/s
View exact numbers
Test name
Executions per second
✓
!!val
10,258,979 Ops/sec
!val
10,022,835 Ops/sec
typeof val !== 'undefined'
9,913,581 Ops/sec
typeof val === 'undefined'
9,744,942 Ops/sec
Script Preparation code:
const undef = undefined function checkIsUndefined(val) { return typeof val === 'undefined' } function checkIsNotUndefined(val) { return typeof val !== 'undefined' } function checkIsTruthy(val) { return !!val } function checkIfFalsey(val) { return !val }
Tests:
typeof val === 'undefined'
checkIsUndefined(undef)
typeof val !== 'undefined'
checkIsNotUndefined(undef)
!!val
checkIsTruthy(undef)
!val
checkIfFalsey(undef)