@s-libs/js-core
    Preparing search index...

    Function getCombinations

    • Gets all combinations of n elements from array.

      getCombinations([1, 2, 3], 2);
      // [
      // [1, 2],
      // [1, 3],
      // [2, 3],
      // ]

      Type Parameters

      • T

      Parameters

      • array: readonly T[]
      • n: 1

      Returns [T][]

    • Gets all combinations of n elements from array.

      getCombinations([1, 2, 3], 2);
      // [
      // [1, 2],
      // [1, 3],
      // [2, 3],
      // ]

      Type Parameters

      • T

      Parameters

      • array: readonly T[]
      • n: 2

      Returns [T, T][]

    • Gets all combinations of n elements from array.

      getCombinations([1, 2, 3], 2);
      // [
      // [1, 2],
      // [1, 3],
      // [2, 3],
      // ]

      Type Parameters

      • T

      Parameters

      • array: readonly T[]
      • n: 3

      Returns [T, T, T][]

    • Gets all combinations of n elements from array.

      getCombinations([1, 2, 3], 2);
      // [
      // [1, 2],
      // [1, 3],
      // [2, 3],
      // ]

      Type Parameters

      • T

      Parameters

      • array: readonly T[]
      • n: 4

      Returns [T, T, T, T][]

    • Gets all combinations of n elements from array.

      getCombinations([1, 2, 3], 2);
      // [
      // [1, 2],
      // [1, 3],
      // [2, 3],
      // ]

      Type Parameters

      • T

      Parameters

      • array: readonly T[]
      • n: number

      Returns T[][]