This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const n = [1,[2,[3,4,5]],6,[7,[8],[9,[10]]]]; | |
const n2 = [1,[2,[3,[4,[5],6],7],8],9]; | |
/** | |
* Flattens arbitrarilily nested arrays. Pulls off the first item (a) from the array | |
* and preserves the rest (arr) using the spread operator. | |
* | |
* @param {Array} [] The nested array to flatten | |
* @param {Array} flat The nested array to flatten | |
* @returns {Array} Recursively returns a flattened array |