# 实现some

function some(array, predicate) {
  let index = -1;
  const length = array == null ? 0 : array.length;
  
  while (++index < length) {
    if (predicate(array[index], index, array)) {
      return true;
    }
  }
  return false;
}

只要断言函数为真值,就会中止遍历。

最近更新时间: 2020/9/6 11:30:38