Created
February 20, 2020 20:16
-
-
Save omarkdev/842e343c41653729cc9bf02956de8ebf to your computer and use it in GitHub Desktop.
This file contains hidden or 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 arr1 = ['a', ['b', ['c']], 1, [2, [3, [4, [5]]]]]; | |
const arr1Flatted1 = arr1.flat(); | |
// ["a", "b", Array(1), 1, 2, Array(2)] | |
const arr1Flatted2 = arr1.flat(2); | |
// ["a", "b", "c", 1, 2, 3, Array(2)] | |
const arr1FlattedInfinity = arr1.flat(Infinity); | |
// ["a", "b", "c", 1, 2, 3, 4, 5] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment