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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser:
Chrome 135
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
typeof val === 'undefined'
178.2M/s
typeof val !== 'undefined'
175.3M/s
!!val
152.2M/s
!val
99.4M/s
View exact numbers
Test name
Executions per second
✓
typeof val === 'undefined'
178,166,000 Ops/sec
typeof val !== 'undefined'
175,270,752 Ops/sec
!!val
152,172,400 Ops/sec
!val
99,374,280 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)