function flatten (arr) {
  return arr.reduce(function (flat, toFlatten) {
    return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
  }, []);
}
/**
 * Flattens an array from any dimension to 1D
 *
 * @param  {Array} arr
 * @return {Array} flattened array
 */
Flattens an array from any dimension to 1D
@param  {Array} arr
@return {Array} flattened array
Flattens an array from any dimension to 1D @param { Array } arr @return { Array } flattened array
function flatten (arr) {
  return arr.reduce(function (flat, toFlatten) {
    return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
  }, []);
}
function flatten ( arr ) { return arr . reduce ( function ( flat , toFlatten ) { return flat . concat ( Array . isArray ( toFlatten ) ? flatten ( toFlatten ) : toFlatten ) ; } , [ ] ) ; }
Flattens an array from any dimension to 1D
 @param  {Array} arr
 @return {Array} flattened array
Flattens an array from any dimension to 1D @param { Array } arr @return { Array } flattened array