array filter

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
//imperative approach
function arrayFilter(arr, func) {
  for (let i of arr) {
    if (func(i)) return i;
  }
  return undefined;
}
ready
// filter method
function arrayFilter(arr, func) {
  let filteredArray = arr.filter(func);
  return filteredArray[0] ? filteredArray[0] : undefined;
}


ready
// find method
function arrayFilter(arr, func) {
  return arr.find(func);
}
ready

Revisions

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