Test name | Executions per second |
---|---|
Array_filter_method | 851703.6 Ops/sec |
classic_for_loop_filter | 648429.1 Ops/sec |
var arr = new Array({ length: 10000 }, () => Math.floor(Math.random() * 1000));
var isGreaterThan500 = val => val > 500;
var filtered = arr.filter(isGreaterThan500)
var l = arr.length
var filtered = [];
for (var i = 0; i < l; i++) {
var val = arr[i];
if (val > 500) {
filtered.push(val);
}
}