Function arrayIntoChunks

  • Convert an array into given chunk(s).

    Type Parameters

    • T

    Parameters

    • arr: T[]

      The original array.

    • n: number

      The number of elements to include in each subarray.

    Returns T[][]

    Array of subarrays, where each subarray contains 'n' elements from the original array.

    Example

    arrayIntoChunks([1,2,3,4,5,6], 3); // [[1,2],[3,4],[5,6]]
    Splits an array into subarrays of length 'n'.

Generated using TypeDoc