uft
    Preparing search index...

    Function forMap

    • Creates an array of values by running each index of the array through a callback function to initialize its value.

      Type Parameters

      • T

      Parameters

      • size: number

        The length of the array to create.

      • cb: (index: number) => T

        The function to initialize each element.

      Returns T[]

      The created array.

      forMap(3, (idx) => idx) // [0, 1, 2]

      forMap(3, (idx) => idx * 2) // [0, 2, 4]

      forMap(2, () => 'foo') // ['foo', 'foo']