Non-destructively reversing an array in Javascript
<p>Say I have a function:</p>

<pre><code>function linesReverser(lines) {
  var localLines = lines.slice(); 
  localLines[1].reverse(); 
  return _.flatten(localLines);
}
</code></pre>

<p>And using it like so:</p>

<pre><code>var input = [["Hello"],["Hello", "World"]["Attention", "Please"]];
var output1 = linesReverser(input); //["Hello", "World", "Hello", "Attention", "Please"]
var output2 = linesReverser(input); //["Hello", "Hello", "World", "Attention", "Please"]
</code></pre>

<p>Notice how the object reference is being shared. I am new to JS, but I thought copying the values would alleviate this issue (<code>line.slice()</code>), but it doesn't seem to work. Is this because of the nested arrays?</p>

<p>How can I non-destructively/immutably perform a reverse?</p>
