Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.some vs. for..of + Break
(version: 0)
Comparing performance of:
Array.some vs for..of + break
Created:
5 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var hasZero = []; var withoutZero = []; for (var i = 0; i < 10000; i++) { hasZero.push(Math.floor(Math.random() * 1000)); withoutZero.push(Math.floor(Math.random() * 1000) + 1) }
Tests:
Array.some
var tempResult = !!Math.round(Math.random()) ? hasZero.some(v => v === 0) : withoutZero.some(v => v === 0);
for..of + break
var found = false; for (var element of Math.round(Math.random()) ? hasZero : withoutZero) { if (element === 0) { found = true; break; } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array.some
for..of + break
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:
Fill array with random integers
Array .push() vs .unshift() with random numbers
Array.prototype.some() vs. Filter vs. Array.prototype.indexOf()
Includes vs Find (Javascript)
Comments
Confirm delete:
Do you really want to delete benchmark?