Array.includes vs Object property getter (v3)

Revision 3 of this benchmark created on


Setup

const arrayWithModuleTypes = new Array(100).fill(true).map((_, index) => `module${index}`)

const objectWithModuleTypes = new Array(100).fill(true).reduce((acc, curr, index) => { return {...acc, [`module${index}`]:`module${index}`}}, {})

const setWithModuleTypes = new Set(arrayWithModuleTypes)

Test runner

Ready to run.

Testing in
TestOps/sec
Array.includes
new Array(600).fill(true).map((_, index) => `module${index}`).forEach((module) => arrayWithModuleTypes.includes(module));
ready
Object property getter
new Array(600).fill(true).map((_, index) => `module${index}`).forEach((module) => !!objectWithModuleTypes[module])
ready
Set getter
new Array(600).fill(true).map((_, index) => `module${index}`).forEach((module) => setWithModuleTypes.has(module));
ready

Revisions

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