some vs for

Benchmark created on


Setup

const item = 2;
const values = [];
for (let i = 0; i < 6; i++) {
    values[i] = i;
}

Test runner

Ready to run.

Testing in
TestOps/sec
some
    if (values.some(value => value / item === 1)) {
        console.log(`found ${item}`)    
    }
ready
for
    for (let i = 0; i < values.length; i++) {
        if (values[i] / item === 1) {
            console.log(`found ${item}`)
        }
    }
ready

Revisions

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