📜  过滤 javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:09.302000             🧑  作者: Mango

代码示例6
function filter(array, filterfunc) {

  let filteredArray = [];
  for (let i = 0; i < array.length; i++) {
    let result = filterfunc(array[i], i, array);
    if (result) {
      filteredArray.push(array[i]);
    }
  }
  return filteredArray;
};