while vs some (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
while
let index = 0;
let hasRetailer = false;
const sanitizedDomain = 'c';
const sanitizedRetailerDomains = ['a', 'b', 'c', 'd', 'e']
const arrayLength = 5;

 while (!hasRetailer && index < arrayLength) {
            hasRetailer = sanitizedRetailerDomains[index] === sanitizedDomain;
            index += 1;
          }
ready
some
let index = 0;
const sanitizedDomain = 'c';
const sanitizedRetailerDomains = ['a', 'b', 'c', 'd', 'e'];

const hasRetailer = sanitizedRetailerDomains.some(x => x === sanitizedDomain);
ready

Revisions

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