Last active
April 23, 2019 17:27
-
-
Save shisama/e1940e588b88b90e61c3984d7d691a9b to your computer and use it in GitHub Desktop.
Array.prototype.flat - New JavaScript Features in Node.js v12
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
var arr1 = [1, 2, [3, 4]]; | |
arr1.flat(); | |
// [1, 2, 3, 4] | |
var arr2 = [1, 2, [3, 4, [5, 6]]]; | |
arr2.flat(); | |
// [1, 2, 3, 4, [5, 6]] | |
var arr3 = [1, 2, [3, 4, [5, 6]]]; | |
arr3.flat(2); | |
// [1, 2, 3, 4, 5, 6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment