OptionalarrayLength: numberGenerates a sequence of numbers, similar to Python's range.
First number, or the length if end is not provided
Optionalend: numberLast number (excluded)
Optionalstep: numberStep between numbers (can be negative)
An array containing the generated sequence
Creates an array filled with a given value or generated using a factory function. Supports creating multi-dimensional arrays by passing multiple sizes.
A multi-dimensional array of the specified depth filled with the given values.
// 1D array with primitive values
const arr1 = Array.create('x', 5);
// type: string[]
// value: ['x', 'x', 'x', 'x', 'x']
// 1D array with random numbers
const arr2 = Array.create(() => Math.random(), 5);
// type: number[]
// value: [0.12, 0.87, 0.45, 0.76, 0.33] (values will differ)
// 2D array (matrix)
const arr3 = Array.create(0, 2, 3);
// type: number[][]
// value: [[0, 0, 0], [0, 0, 0]]
// 2D array with distinct objects
const arr4 = Array.create(() => ({ id: 0 }), 2, 3);
// type: { id: number }[][]
// value: [
// [{ id: 0 }, { id: 0 }, { id: 0 }],
// [{ id: 0 }, { id: 0 }, { id: 0 }]
// ]
Combines multiple arrays element-wise, similar to Python's
itertools.zip_longest.