HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
 
var arr = [
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['sent'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
  { status: ['draft'] },
]
Tests:
  • Original

     
    for (const assignment of arr) {
      if (_.get(assignment, 'status[0]') !== 'sent') {
        hasInvalidStatus = true;
        break;
      }
    }
  • Lodash

     
    _.some(arr, a=>a.status[0]!== 'sent');
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Original
    Lodash

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Chrome 83 on Mac OS X 10.14.5
View result in a separate tab
Test name Executions per second
Original 1440153.8 Ops/sec
Lodash 3888207.8 Ops/sec