Skip to content

Instantly share code, notes, and snippets.

@Joaquin6
Created September 28, 2016 09:30
Show Gist options
  • Save Joaquin6/a6b0279925c1d25aba70c3e709301ef3 to your computer and use it in GitHub Desktop.
Save Joaquin6/a6b0279925c1d25aba70c3e709301ef3 to your computer and use it in GitHub Desktop.
Flatten an array of arbitrarily nested arrays of integers into a flat array of integers in Node.js.
var _ = require("underscore");
var nestedArray = [[1,2,[3]],4];
var flattenArray = _.flatten(nestedArray);
console.log(flattenArray);
// => [1, 2, 3, 4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment