📜  typescript 按条件拆分分区数组 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:27.555000             🧑  作者: Mango

代码示例1
const [small, large] =                             // Use "deconstruction" style assignment
  [12, 5, 8, 130, 44]
    .reduce((result, element) => {
      result[element <= 10 ? 0 : 1].push(element); // Determine and push to small/large arr
      return result;
    },
    [[], []]);                                     // Default small/large arrays are empty