Two levels arrays

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
function flattenTwoLevels(array) {
var result = [];
array.forEach(function(val) {
if (val instanceof Array && val.some(function(item) {return item instanceof Array;}))
result.push(Array.prototype.concat.apply([], flattenTwoLevels(val)));
else
result.push(val);
});
return result;
}