SHARE
TWEET

Untitled

a guest Mar 26th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const multiDimensionalArray = [ [1, 2], [3, 4], [5, 6] ];
  2. const flattenedArray =multiDimensionalArray.flat();
  3. console.log(flattenedArray) // [1, 2, 3, 4, 5, 6]
  4.  
  5. // This methods accepts one argument to choose the depth of the flattening.
  6. const multiDimensionalArray = [[ [1, 2]], [3, 4], [5, 6] ];
  7. multiDimensionalArray.flat(2);
  8. console.log(flattenedArray) // [1, 2, 3, 4, 5, 6]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top