javascript array filter versus loop

JavaScript performance comparison

Revision 22 of this test case created by

Preparation code

Benchmark.prototype.setup = function() {
  var input = [0,1,2,3,4,5,6,7,8,9];


Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
loop fixed count
var output = [], inputCount = input.length;
for(var i=0; i<inputCount; i++) {
    if(i % 2) output.push(input[i]);


You can edit these tests or add even more tests to this page by appending /edit to the URL.