For loop vs filter octagon

Benchmark created by Henk on


Test runner

Ready to run.

Testing in
TestOps/sec
for loop
var testArr = 'test woord';
var filteredArr = [];
for(var i = 0; i < testArr.length; i++) {
 if(testArr[i] != 'o') filteredArr.push(testArr[i]);
}
console.log(filteredArr);
ready
filter
var testArr = 'test woord';
testArr = testArr.split('').filter(function(i) { if(i == 'o') return true; });
console.log(testArr);
 
ready

Revisions

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