Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array filter vs. for loop (fixedN)
(version: 0)
Comparing performance of:
Filter vs For vs For 2
Created:
5 years 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;i<arr.length;i++) { if (arr[i]<5) continue; farr.push(arr[i]); }
For 2
for (var i=0;i<arr.length;i++) { 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 2
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Array filter vs. for loop - with for in 2
Array filter vs. for loop and for in
Array filter vs. for loop (fixed)2
flatMap() vs filter().map() - arrays
Comments
Confirm delete:
Do you really want to delete benchmark?