Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array every vs some vs for loop
(version: 0)
Comparing performance of:
every vs for of loop vs for loop vs reduce
Created:
5 years ago
by:
Guest
Jump to the latest result
Tests:
every
const a = [1, 2, 3, 4, 5]; const b = [1, 2, 4, 5, 3, 5]; a.every(x => b.some(y => x === y));
for of loop
const a = [1, 2, 3, 4, 5]; const b = [1, 2, 4, 5, 3, 5]; for (let x of a) { if (!b.some(y => x === y)) { break; } }
for loop
const a = [1, 2, 3, 4, 5]; const b = [1, 2, 4, 5, 3, 5]; for (let i = 0; i < a.length; i++) { if (!b.some(y => a[i] === y)) { break; } }
reduce
const a = [1, 2, 3, 4, 5]; const b = [1, 2, 4, 5, 3, 5]; a.reduce((x, y, i) => i === 0 ? b.some(p => p === x) : b.some(p => p === y))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
every
for of loop
for loop
reduce
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:
foreach vs for..of
For loop vs <Array>.forEach() vs for...of loop
for vs every simple
for vs foreach123
for vs every simple32
Comments
Confirm delete:
Do you really want to delete benchmark?