lib/array.js
function flatten(a) {
  return a.reduce(function(flat, val) {
    if (val && typeof val.flatten === 'function') {
      flat = flat.concat(val.flatten());
    }
    else if (Array.isArray(val)) {
      flat = flat.concat(flatten(val));
    }
    else {
      flat.push(val);
    }
    return flat;
  });
}
function flatten(a) {
  return a.reduce(function(flat, val) {
    if (val && typeof val.flatten === 'function') {
      flat = flat.concat(val.flatten());
    }
    else if (Array.isArray(val)) {
      flat = flat.concat(flatten(val));
    }
    else {
      flat.push(val);
    }
    return flat;
  });
}
function flatten ( a ) { return a . reduce ( function ( flat , val ) { if ( val && typeof val . flatten === 'function' ) { flat = flat . concat ( val . flatten ( ) ) ; } else if ( Array . isArray ( val ) ) { flat = flat . concat ( flatten ( val ) ) ; } else { flat . push ( val ) ; } return flat ; } ) ; }
Based on underscore.js's flatten
Based on underscore . js s flatten