• Fill an array with a static value.

    Type Parameters

    • T

    Parameters

    • array: MutableArrayLike<T>

      The mutable array-like object to fill.

    • value: T

      The static value to use to fill the array.

    • start: number = 0

      The index of the first element in the range to be filled, inclusive. The default value is 0. Negative values are taken as an offset from the end of the array.

    • stop: number = -1

      The index of the last element in the range to be filled, inclusive. The default value is -1. Negative values are taken as an offset from the end of the array.

      Notes

      If stop < start the fill will wrap at the end of the array.

      Complexity

      Linear.

      Undefined Behavior

      A start or stop which is non-integral.

      Example

      import { ArrayExt } from '@lumino/algorithm';

      let data = ['one', 'two', 'three', 'four'];
      ArrayExt.fill(data, 'r'); // ['r', 'r', 'r', 'r']
      ArrayExt.fill(data, 'g', 1); // ['r', 'g', 'g', 'g']
      ArrayExt.fill(data, 'b', 2, 3); // ['r', 'g', 'b', 'b']
      ArrayExt.fill(data, 'z', 3, 1); // ['z', 'z', 'b', 'z']

    Returns void