Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.filter vs push
Compare array ops to remove elements from array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Browser:
Chrome 127
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
filter
115287.3 Ops/sec
push
495375.4 Ops/sec
Script Preparation code:
var array = []; for (var idx = 0; idx < 1000; idx++) { array[idx] = idx; } function oddNum(item) { return item % 2; } // Create a new array and push to it Array.prototype.pushFilter = function(condition) { // Create a new array and push to it var result = []; for(var i = 0, len = this.length; i < len; i++) { if (condition(this[i], i, this)) result.push(this[i]); } return result; };
Tests:
filter
var result = array.filter(oddNum);
push
var result = array.pushFilter(oddNum);