Fast Array Length Checks

Benchmark created on


Setup

const array = [1, 2, 3];
const length = array.length;

function strictEquality () {
	if (length === 0) return;
	// Should just pass through
}

function nonStrictEquality () {
	if (length == 0) return;
	// Should just pass through
}

function lessThanOrEqualTo () {
	if (length <= 0) return;
	// Should just pass through
}

Test runner

Ready to run.

Testing in
TestOps/sec
Strict equality ===
strictEquality();
ready
Non-strict Equality ==
nonStrictEquality();
ready
Less than or equal to <=
lessThanOrEqualTo();
ready

Revisions

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