Test name | Executions per second |
---|---|
lodash filter | 2043237.0 Ops/sec |
lodash compact | 3640652.5 Ops/sec |
Native filter | 5335408.0 Ops/sec |
<script src="https://cdn.jsdelivr.net/lodash/4.16.0/lodash.min.js"></script>
var ops = [null, 1, 2, 3, 4, 5, null, null, null, 3, 4,5, 6, 34,341,2,2,2,1,212,21212,34,1,3112, null];
_.filter(ops, op => !!op)
_.compact(ops)
ops.filter(op => !!op)