filter vs find

Benchmark created on


Setup

const objs = [];
for (let i = 0; i < 1000; i++) {
	objs.push({id: i});
}

Test runner

Ready to run.

Testing in
TestOps/sec
filter
const y = objs.filter(obj => obj.id === 773)[0];
console.log(y);
ready
find
const y = objs.find(obj => obj.id === 773);
console.log(y);
ready

Revisions

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