Flattens nested array to given depth.
npm install @extra-array/flattenFlattens nested array to given depth.
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
``javascript`
array.flatten(x, [dep]);
// x: a nested array
// dep: maximum depth (-1)
// --> flattened
`javascript
const array = require('extra-array');
var x = [[1, 2], [3, [4, [5]]]];
array.flatten(x);
// [1, 2, 3, 4, 5]
array.flatten(x, 1);
// [1, 2, 3, [4, [5]]]
array.flatten(x, 2);
// [1, 2, 3, 4, [5]]
``