Skip to content

Instantly share code, notes, and snippets.

@janumpallykalyan
janumpallykalyan / flatten.js
Created October 8, 2017 10:01
nested arrays of integers into a flat array of integers
var data = [[1,2,[3]],4];
function flatten(array) {
var output = [];
array.forEach(function(value) {
if(value instanceof Array) {
output = output.concat(flatten(value));
} else {
output.push(value)
}