Skip to content

Instantly share code, notes, and snippets.

@mikaeelkhalid
Last active October 20, 2021 11:06
Show Gist options
  • Save mikaeelkhalid/3dac93ac1a2951e051aeced51cbedf43 to your computer and use it in GitHub Desktop.
Save mikaeelkhalid/3dac93ac1a2951e051aeced51cbedf43 to your computer and use it in GitHub Desktop.
Javascript alternative way to flatten an array
const arr = [1, [7, 8], 2, 3, 4, 5, [6, 9, 10]];
const flat = [].concat(...arr);
console.log(flat); // output: [1, 7, 8, 2, 3, 4, 5, 6, 9, 10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment