checking

Benchmark created on


Setup

const statuses = {
	idle: 'idle',
	loading: 'loading',
	error: 'error',
	ready: 'ready'
};

const status = 'ready';

function checkIsInStatus(status) {
	return status === 'idle' || status === 'loading' || status === 'error' || status === 'ready';
}

Test runner

Ready to run.

Testing in
TestOps/sec
IndexOf
const isInStatus = [statuses.idle, statuses.loading, statuses.error, statuses.ready].indexOf(status);
ready
check every in enum
const isInStatus = status === statuses.idle || status === statuses.loading || status === statuses.error || status === statuses.ready
ready
check by value
const isInStatus = status === 'idle' || status === 'loading' || status === 'error' || status === 'ready'
ready
indexof raw value
const isInStatus = ['idle', 'loading', 'error', 'ready'].indexOf(status);
ready
check by value in function
const isInStatus = checkIsInStatus(status);
ready

Revisions

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