Test name | Executions per second |
---|---|
foreach | 2961126.8 Ops/sec |
for in | 3344721.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 count = 0;
_.forEach(values, function(v,i) {
if (v.a != null) {
count++;
}
})
var count = 0;
for(var value in values) {
if (value.a != null) {
count++;
}
}