arr.flat().some(fn) vs arr.some(a => a.some(fn))

Benchmark created on


Setup

const arr = [
	[0,1,2,3,4,5,6,7,8,9],
	[0,1,2,3,4,5,6,7,8,9],
	[0,1,2,3,4,5,6,7,8,9],
	[0,1,2,3,4,5,6,7,8,9],
	[0,1,2,3,4,5,6,7,8,9],
	[0,1,2,3,4,50,6,7,8,9],
	[0,1,2,3,4,5,6,7,8,9],
	[0,1,2,3,4,5,6,7,8,9],
	[0,1,2,3,4,5,6,7,8,9],
	[0,1,2,3,4,5,6,7,8,9]
]

Test runner

Ready to run.

Testing in
TestOps/sec
arr.flat().some(fn)
arr.flat().some((x) => x === 50)
ready
arr.some(a => a.some(fn))
arr.some((a) => a.some((x) => x === 50))
ready

Revisions

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