Last active
October 20, 2021 11:06
-
-
Save mikaeelkhalid/3dac93ac1a2951e051aeced51cbedf43 to your computer and use it in GitHub Desktop.
Javascript alternative way to flatten 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 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