Last active
May 30, 2020 00:50
-
-
Save if540/8aebbc29c1da85c9f1a7a1634091b0c0 to your computer and use it in GitHub Desktop.
Deep flattens an array.
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 deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); | |
// deepFlatten([1, [2], [[3], 4], 5]); // [1,2,3,4,5] |
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 isUndefined = val => val === undefined; | |
// isUndefined(undefined); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment