HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
x
 
// empty array
window.foo1 = [];
// array of strings
window.foo2 = ['a', 'b', 'c', 'd', 'e'];
// array of objects
window.foo3 = { a: 1, b: 2, c: 3, d: 4, e: 5};
Tests:
  • isEmpty empty array

     
    _.isEmpty(window.foo1);
  • length empty array

     
    window.foo1.length === 0;
  • isEmpty array of strings

     
    _.isEmpty(window.foo2);
  • length array of strings

     
    window.foo2.length === 0;
  • isEmpty on object

     
    _.isEmpty(window.foo3);
  • length of object

     
    Object.keys(window.foo3).length === 0;
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    isEmpty empty array
    length empty array
    isEmpty array of strings
    length array of strings
    isEmpty on object
    length of object

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36
Chrome 104 on Linux
View result in a separate tab
Test name Executions per second
isEmpty empty array 4828587.5 Ops/sec
length empty array 10844446.0 Ops/sec
isEmpty array of strings 4970387.5 Ops/sec
length array of strings 11270569.0 Ops/sec
isEmpty on object 5206565.5 Ops/sec
length of object 5999092.5 Ops/sec