Test name | Executions per second |
---|---|
lodash.forEach | 2565.9 Ops/sec |
native | 25043.0 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 (let v of valArr) {
if (v.a != null) {
count++;
}
}