Array vs includes

Benchmark created on


Setup

const array = ['Success', 'Error', 'Warning'];
const set = new Set(array);

Test runner

Ready to run.

Testing in
TestOps/sec
Array
const x = {
            error: array.includes('Error'),
            success: array.includes('Success'),
            warning: array.includes('Warning'),
          }
ready
Set
const x = {
            error: set.has('Error'),
            success: set.has('Success'),
            warning: set.has('Warning'),
          }
ready

Revisions

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