Skip to content

Instantly share code, notes, and snippets.

@MauricioMoraes
Created October 22, 2015 12:00
Show Gist options
  • Select an option

  • Save MauricioMoraes/225afcc9dd72acf1511f to your computer and use it in GitHub Desktop.

Select an option

Save MauricioMoraes/225afcc9dd72acf1511f to your computer and use it in GitHub Desktop.
Javascript Flatten (for one level nested arrays) - Useful for google apps scripts on spreadsheets
// Takes and array of arrays matrix and return an array of elements.
function flatten(arrayOfArrays){
return [].concat.apply([], arrayOfArrays);
}
@illia108

illia108 commented May 2, 2019

Copy link
Copy Markdown

Good one. Thanks. Do you know why flat() doesn't work in google apps script?

@John-Dox

Copy link
Copy Markdown

thanks

@mommalibrarian

Copy link
Copy Markdown

The before and after arrays look the same in Logger.log. How can you tell they have changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment