Tweakr
    Preparing search index...

    Function fill

    • Fills elements of an array with a specified value from the start index up to, but not including, the end index.

      Type Parameters

      • T

      Parameters

      • array: T[]

        The array to fill.

      • value: T

        The value to fill the array with.

      • start: number = 0

        The start position (inclusive). Defaults to 0.

      • end: number = array.length

        The end position (exclusive). Defaults to the array length.

      Returns T[]

      A new array with the specified range filled with the given value.

      fill([1, 2, 3, 4], 0, 1, 3);
      // → [1, 0, 0, 4]

      fill([1, 2, 3], 5);
      // → [5, 5, 5]

      1.0.0