Test if an object containing a specific value exists in an array

Benchmark created on


Setup

const arr = [{ foo: 1 }, { foo: 2 }, { foo: 3 }]

Test runner

Ready to run.

Testing in
TestOps/sec
forEach()
let fulfilled = false
arr.forEach(item => { if (item.foo === 2) fulfilled = true })
ready
find()
arr.find(item => item.foo === 2)
ready
findIndex()
arr.findIndex(item => item.foo === 2) !== -1
ready
some()
arr.some(item => item.foo === 2)
ready

Revisions

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