Options
All
  • Public
  • Public/Protected
  • All
Menu

Module fill

Index

Functions Array

Array Functions

  • fill<T>(array: any[], value?: T): T[]
  • fill(array: any[], value?: any, start?: number, end?: number): any[]
  • Fills elements of array with value from start up to, but not including, end.

    Note: This method mutates array.

    static
    since

    5.10.0

    example
    var array = [1, 2, 3];

    fill(array, 'a');
    console.log(array);
    // => ['a', 'a', 'a']

    fill(Array(3), 2);
    // => [2, 2, 2]

    fill([4, 6, 8, 10], '*', 1, 3);
    // => [4, '*', '*', 10]

    Type Parameters

    • T

    Parameters

    • array: any[]

      The array to fill.

    • Optional value: T

      The value to fill array with.

    Returns T[]

    Returns array.

  • Parameters

    • array: any[]
    • Optional value: any
    • Optional start: number
    • Optional end: number

    Returns any[]