Array includes over Object key

Benchmark created on


Setup

const length = 1000;
const flagsMap = Array(length).fill(null).reduce((acc,_,i) => {
	acc[i] = Math.floor(Math.random() * 2) ? true: false;
    return acc;
},{});

const flagsEnabledArray = Array(length).fill(null).map((_,i) => i);


Test runner

Ready to run.

Testing in
TestOps/sec
Array includes
for(i=0; i<length; i++) {
	flagsEnabledArray.includes(i);
}
ready
Object key
for(i=0; i<length; i++) {
	flagsMap[i];
}
ready

Revisions

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