Node.js lodash flatten()
flatten array
var _ = require('lodash'); // get an array of the values, changing any subarrays to flattend values var values2 = [ 1, 3, 4, [ 6, 8, 9]]; var v2 = _.flatten(values2); console.log(v2);//from w w w . ja v a 2 s . co m //Flattens a nested array. //If isDeep is true the array is recursively flattened, //otherwise it is only flattened a single level. var withoutdeep = _.flatten([1, [2, 3, [4]]]); console.log(withoutdeep); var withisdeep = _.flatten([1, [2, 3, [4]]], true); console.log(withisdeep);