javascript Finders Keepers

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Finders Keepers相关的知识,希望对你有一定的参考价值。

function findElement(arr, func) {
  // loop through array
  for (let i = 0; i < arr.length; i++) {
    // truth test, return array element for pass, undefined for fail
    if ( func(arr[i]) ) { return arr[i]; }

  }
  // no element in array has passed truth test, return undefined
  return undefined;
}

findElement([1, 2, 3, 4], num => num % 2 === 0);

以上是关于javascript Finders Keepers的主要内容,如果未能解决你的问题,请参考以下文章

Finders Keepers

Finders Keepers

当字段有下划线时,Magic Doctrine2 finders?

FCC 中级算法题 Finders Keepers

ClickHouse-Keeper调研

haproxy keeper