Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array filter vs for ...of loop
Array filter vs for ...of loop Comparing performance of:
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Filter
9947192.0 Ops/sec
For ... of
2575070.5 Ops/sec
Script Preparation code:
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; const far = [];
Tests:
Filter
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; const far = []; farr = arr.filter(function(item) { return (item>4); });
For ... of
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; const far = []; for (const item of arr) { if (item > 4) { farr.push(item); } }