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
Test name
Executions per second
typeof val === 'undefined'
178166000.0 Ops/sec
typeof val !== 'undefined'
175270752.0 Ops/sec
!!val
152172400.0 Ops/sec
!val
99374280.0 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)