Includes on simple array vs Some on nested data

Benchmark created on


Preparation HTML

let demo = Array.from({ length: 10000 }, (_, i) => ({
  id: Math.floor(Math.random() * 100000),
  video: {
    id: i,
  }
}));

const computed = demo.map((val) => val.video.id)


const demoA = (id) => computed.includes(id)

const demoB = (id) => demo.some(val => val.video.id === id)


Test runner

Ready to run.

Testing in
TestOps/sec
Includes
console.log(demoA(5000))
ready
Some
console.log(demoB(5000))
ready

Revisions

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