Skip to content

Instantly share code, notes, and snippets.

@if540
Last active May 30, 2020 00:50
Show Gist options
  • Save if540/8aebbc29c1da85c9f1a7a1634091b0c0 to your computer and use it in GitHub Desktop.
Save if540/8aebbc29c1da85c9f1a7a1634091b0c0 to your computer and use it in GitHub Desktop.
Deep flattens an array.
const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v)));
// deepFlatten([1, [2], [[3], 4], 5]); // [1,2,3,4,5]
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