Array.filter (v6)

Revision 6 of this benchmark created on


Setup

var arrayToFilter = [1, 2, 3, undefined, 4, null, 10, -1, "a"]

Test runner

Ready to run.

Testing in
TestOps/sec
.filter((v) => v)
arrayToFilter.filter((v) => v)
ready
.filter(Boolean)
arrayToFilter.filter(Boolean)
ready
for loop
const output = []
for (const el of arrayToFilter) {
	if (!el) continue;
	
	output.push(el);
}
ready

Revisions

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