Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
isArray vs nullish coalesce + length check
(version: 1)
Array.isArray vs array.length > 0
Comparing performance of:
Array.isArray vs Check object.length
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
function myIsArray(obj){ return (obj ?? []).length > 0; } var isArray = Array.isArray
Tests:
Array.isArray
isArray([])
Check object.length
myIsArray([])
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array.isArray
Check object.length
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15
Browser/OS:
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array.isArray
601194432.0 Ops/sec
Check object.length
132709568.0 Ops/sec
Related benchmarks:
isArray2
isArray3
isArray vs length
isArray vs length (with alpha)
isArray vs length2
isArray vs optional length
isArray vs optional length 2
!!array.length vs array.length > 0
array.length vs array.length > 0 2
Comments
Confirm delete:
Do you really want to delete benchmark?