For vs Some

Benchmark created on


Setup

var data = Array.from({ length: 4096 }, (() => 0));
data[2048] = 1;

Test runner

Ready to run.

Testing in
TestOps/sec
for loop
function forLoop() {
	for (let i = 0; i < data.length; i++) {
		if (data[i] != 0) return true;
	}
	return false;
}


let value = forLoop();
ready
some
function someCheck() {
	return data.some((e) => e != 0);
}

let value = someCheck();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.