Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array filter vs. for loop (fixed really really)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 15; Mobile; rv:148.0) Gecko/148.0 Firefox/148.0
Browser:
Firefox Mobile 148
Operating system:
Android
Device Platform:
Mobile
Date tested:
one month ago
Test name
Executions per second
Filter
12783667.0 Ops/sec
For
3734460.0 Ops/sec
For 2
2874524.5 Ops/sec
Script Preparation code:
var arr = [1,2,3,4,5,6,7,8,9,0], farr;
Tests:
Filter
farr = arr.filter(function(item) { return (item>4); });
For
for (var i=0,len=arr.length;i<len;i++) { if (arr[i]<5) continue; farr.push(arr[i]); }
For 2
for (var i=0,len=arr.length;i<len;i++) { if (arr[i]>4) farr.push(arr[i]); }