Returns a new
Array
with the given maximum length
$ npm install array-max-length
const arrayMaxLength = require('array-max-length');
const arr = [1, 2, 3, 4, 5];
arrayMaxLength(arr, 2);
// => [1, 2]
arrayMaxLength(arr, 10);
// => [1, 2, 3, 4, 5]
Returns a new Array
with the given length.
Type: Array
Input to return the new Array
from.
Type: number
The maximum length of the Array
.
MIT © Andreas Gillström