用管道替换循环

refactorgram

  const names = [];
  for (const i of input) {
    if (i.job === "programmer")
      names.push(i.name);
  }

image/svg+xml

  const names = input
    .filter(i => i.job === "programmer")
    .map(i => i.name)
  ;