Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array[0] vs array.length > 0
(version: 1)
Comparing performance of:
array length vs array length > 0
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = [];
Tests:
array length
if (arr[0]) { console.log(1); } else { console.log(0); }
array length > 0
if (arr.length > 0) { console.log(1); } else { console.log(0); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
array length
array length > 0
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/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array length
727955.8 Ops/sec
array length > 0
721651.8 Ops/sec
Related benchmarks:
array.length vs array.length > 0
!array.length vs array.length === 0
array.length vs array.length != 0
array.length vs array.length > 0 vs !!array.length
array.length !==0 vs array.length > 0
!!array.length vs array.length > 0
array.length vs array.length > 0 vs array.length !== 0
array.length vs array.length === 0
Compare !array.length vs array.length === 0
array.length vs array.length > 0 v2
Comments
Confirm delete:
Do you really want to delete benchmark?