Created
December 16, 2017 06:17
-
-
Save tonkatsu7/da13751a9ad08ecc773c2c76b808a858 to your computer and use it in GitHub Desktop.
Flatten a javascript 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
var arr1 = ['a', 'b', 'c']; | |
console.log(arr1.length); | |
var arr2 = ['d', 'e', 'f']; | |
console.log(arr2.length); | |
var arr3 = ['g', 'h', 'i']; | |
console.log(arr3.length); | |
var nested = [arr1, arr2, arr3]; | |
console.log('nested=' + nested); | |
console.log(nested.length); | |
var flattened = [].concat.apply([], nested); | |
console.log('resut=' + flattened); | |
console.log(flattened.length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment