@nevware21/ts-utils
    Preparing search index...

    Function arrFill

    • The arrFill() method changes all elements in an array to a static value, from a start index (default 0) to an end index (default array.length). It returns the modified array. This method mutates the array.

      Type Parameters

      • T

        Identifies the type of array elements

      Parameters

      • theArray: WritableArrayLike<T>

        The array to fill

      • value: T

        Value to fill the array with

      • Optionalstart: number

        Start index (inclusive), defaults to 0. Negative index counts from the end

      • Optionalend: number

        End index (exclusive), defaults to array.length. Negative index counts from the end

      Returns WritableArrayLike<T>

      The modified array

      0.14.0

      arrFill([1, 2, 3], 0);              // [0, 0, 0]
      arrFill([1, 2, 3], 4, 1); // [1, 4, 4]
      arrFill([1, 2, 3], 5, 1, 2); // [1, 5, 3]
      arrFill([1, 2, 3], 6, -2); // [1, 6, 6]
      arrFill([1, 2, 3], 7, -3, -1); // [7, 7, 3]
      arrFill([], 1); // []