in vs [] (v2)

Revision 2 of this benchmark created on


Setup

const old = {
      1: ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'],
      2: ['D', 'G'],
      3: ['B', 'C', 'M', 'P'],
      4: ['F', 'H', 'V', 'W', 'Y'],
      5: ['K'],
      8: ['J', 'X'],
      10: ['Q', 'Z'],
    };

Test runner

Ready to run.

Testing in
TestOps/sec
[]
function hasX(key){
	return !!old[key];
}


let xx= 0;
for(let i = 0; i< 10000; i++){
	if(hasX(i)){
		xx++;
	}
}
ready
in
function hasX(key){
	return key in old;
}

let xx= 0;
for(let i = 0; i< 10000; i++){
	if(hasX(i)){
		xx++;
	}
}
ready

Revisions

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