Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array filter vs. for loop - with for in -cc
(version: 1)
Comparing performance of:
Filter vs For vs For in
Created:
8 months ago
by:
Guest
Jump to the latest result
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 in
for (var i of arr) { if (arr[i]>4) farr.push(arr[i]); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Filter
For
For in
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0
Browser/OS:
Firefox 142 on Ubuntu
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Filter
39210124.0 Ops/sec
For
6036600.5 Ops/sec
For in
2499089.5 Ops/sec
Related benchmarks:
Array filter vs. for loop (fixed really really)
Array filter vs. for loop - with for in
Array filter vs. for loop - with for in 2
Array filter vs. for loop - with for in 2
Array filter vs. for loop - with for in 2
Array filter vs. for loop (fixed 2)
Array filter vs. for loop (fixed)2
Array filter vs. for loop - with for of
Array filter vs. for loops with for of
Comments
Confirm delete:
Do you really want to delete benchmark?