Creates a 1-dimensional array to fit a grid of rows x cols. Use createArray if you want to create this array and wrap it for grid access.

// Creates an array filled with 0, sized for a grid 10 rows by 20 columns
const arr = createArray(0, 10, 20);

// Alternatively, pass in a grid
const arr = createArray(0, { rows: 10, cols: 20 });
  • Type Parameters

    • T

    Parameters

    • initialValue: T
    • rowsOrGrid: number | Grid

      Number of rows, or a grid to use the settings of

    • Optionalcolumns: number

      Columns

    Returns T[]