Test name | Executions per second |
---|---|
lodash.forEach | 2571.7 Ops/sec |
native | 217.9 Ops/sec |
<script src="https://cdn.jsdelivr.net/lodash/4.16.0/lodash.min.js"></script>
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
});
}
var count = 0;
_.forEach(valArr, function(v,i) {
if (v.a != null) {
count++;
}
})
var count = 0;
for (var i = 0; i < valArr.length; i++) {
if (valArr[i].a != null) {
count++;
}
}