Includes on simple array vs Some on nested data (v2)

Revision 2 of this benchmark created on


Preparation HTML



Setup

let demo = Array.from({ length: 1000 }, (_, 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(-1))
ready
Some
console.log(demoB(-1))
ready

Revisions

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