Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36
Chrome 84
Mac OS X 10.14.6
Desktop
4 years ago
Test name Executions per second
lodash.forEach 2571.7 Ops/sec
native 217.9 Ops/sec
HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/lodash/4.16.0/lodash.min.js"></script>
Script Preparation code:
x
 
var values = [{
    a: 30310
}, {
    b: 100303
}, {
    c: 3040494
}]
var valArr = [];
for (let i = 0; i < 20000; i++) {
    valArr.push({
        a: 1,
        b: 2,
        c: 3
    });
}
Tests:
  • lodash.forEach

     
    var count = 0;
    _.forEach(valArr, function(v,i) {
      if (v.a != null) {
        count++; 
      }
    })
  • native

     
    var count = 0;
    for (var i = 0; i < valArr.length; i++) {
      if (valArr[i].a != null) {
        count++; 
      }
    }