title: How would you use .reduce() on arguments instead of a specific array or object?
body: <p>I want to define a function .flatten that flattens several elements into one single array. I know that the following is not possible, but essentially I would like to do this:</p>
  
  <pre><code>var flatten = function() {
     var flattened = arguments.reduce(function(acc, elem) { return acc.concat(elem) }, []);
     return flattened;
  }; 
  
  var arr = [[1,2,3], 4, 5, [6, 7]];
  console.log(flatten(arr)) // =&gt; [1,2,3,4,5,6,7]
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>TypeError: arguments.reduce is not a function
  </code></pre>
  
  <p>I understand that the above error is because arguments is only array-like, so it does not have the full capabilities of a true array. So there is the following, but I'm wondering if there is something even cleaner: </p>
  
  <pre><code>var flatten = function() {
    var flattened = [].reduce.call(arguments, function(acc, elem) { return acc.concat(elem) });
    return flattened;
  };
  </code></pre>
  
  <p>Any good way to rewrite .flatten using .reduce()?</p>
  
  <p>NOTE: I know there are many other ways that you can flatten arrays in javascript, but what I was wondering about here is how to do so with specifically <em>arguments</em>. </p>