init-array
Creates new array with defined size and initial value
Install
npm install --save init-array
Usage
Arguments:
- dimensions
- value to assign
var newArray = ; ; // [ 0, 0, 0 ]; // [ 256 ]; // [ [ 0, 0 ], [ 0, 0 ], [ 0, 0 ] ]; // [ 'test', 'test' ]; // [ [ 1, 1, 1 ], [ 1, 1, 1 ] ]// etc
If value argument is function then executes this function for each element.
; // [ 0.5508887629402555, 0.7256682864214947, 0.8916228685296357 ] var i = 0; // [ [ 0, 1 ], [ 2, 3 ] ]
Testing
npm test