Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Filter vs for
(version: 1)
Comparing performance of:
Filter vs for of
Created:
one year ago
by:
Registered User
Go to the latest result
Script Preparation code:
window.parentObj = []; for (let i = 0; i < 1000; i++) { window.parentObj.push(Math.floor(Math.random() * 4294967295)); }
Tests:
Filter
const newObj = window.parentObj.filter(n => n % 2);
for of
const newObj = []; for (const n of window.parentObj) { if ((n % 2) === 0) { newObj.push(n); } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Filter
for of
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser/OS:
Chrome 130 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Filter
73K/s
for of
66K/s
View exact numbers
Test name
Executions per second
✓
Filter
72,990 Ops/sec
for of
66,474 Ops/sec
Related benchmarks
Some vs. Filter vs. indexOf
Some vs. Filter vs. indexOf 1
Some vs. Filter vs. indexOf vs every
Comments
Confirm delete:
Do you really want to delete benchmark?