Initialize new dimensional array
Create a new multi-dimensional array with initialized values.
Example
let inda = ; // A single-dimensional array where all values are 23;// [23, 23, 23] // An array with different values via callbacklet i = 0; 3);// [0, 1, 2] // A two-dimensional array;// [[1, 1, 1], [1, 1, 1]] // A 12-dimensional array;// [[[[[[[[[[[[1]]]]]]]]]]]] // Assigning a function as a value;// [() => 6, () => 6)]
Installation
$ npm install inda
API
var inda = ;
inda(initialValue, size, ...sizes)
Type | Data Type | Name | Description |
---|---|---|---|
parameter | * | initialValue | A value to each element in the array. If a callback is provided, the returned value will be used. |
parameter | number | size | The size of the array to return. |
parameter | ...number | sizes | The sizes of nested-arrays. |
returns | *[] | An array of initialized values. |
Links
- Github: inda