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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Filter
5221698.5 Ops/sec
For ... of
1535900.4 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); } }