find vs some

Benchmark created on


Setup

const array = [];
const arraySize = 10000;

for (let i = 0; i < arraySize; i++) {
	array.push({
		libelle: i
	});
}

const valueMin = 0;
const valueMid = Math.floor(arraySize/2);
const valueMax = arraySize - 1;
const valueUnfindable = -1;

Test runner

Ready to run.

Testing in
TestOps/sec
find
array.find(a => a.libelle === valueMin);
array.find(a => a.libelle === valueMid);
array.find(a => a.libelle === valueMax);
array.find(a => a.libelle === valueUnfindable);
ready
some
array.some(a => a.libelle === valueMin);
array.some(a => a.libelle === valueMid);
array.some(a => a.libelle === valueMax);
array.some(a => a.libelle === valueUnfindable);
ready

Revisions

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