Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
check empty array
(version: 0)
isArray or array. lenght?
Comparing performance of:
useing isArray vs useing length
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
const array = [{a:2, b:4}, {a:3, b:6}, {a:5, b:9}] const emptyArray = []
Tests:
useing isArray
if(Array.isArray(array)) console.log('array'); if(Array.isArray(emptyArray)) console.log('emptyArray');
useing length
if(array?.length) console.log('array'); if(emptyArray?.length) console.log('emptyArray');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
useing isArray
useing length
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?