title: What is the equivalent of Java `Collection.addAll` for JavaScript arrays?
body: <p>Java Collections have a method to add all elements of another collection: <a href="https://docs.oracle.com/javase/7/docs/api/java/util/Collection.html#addAll(java.util.Collection)" rel="noreferrer"><code>addAll(Collection other)</code></a>.</p>
  
  <p>What is the equivalent to do in place appending of javascript arrays?</p>
  
  <p>We cannot use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat" rel="noreferrer"><code>Array.concat</code></a>, because it creates a new array and leaves the original array untouched.</p>
  
  <p>So, given two arrays, how <code>b</code> to <code>a</code>, how to append all elements of <code>b</code> to <code>a</code> in place (therefore <code>c</code> also changes!):</p>
  
  <pre><code>var a = [1, 2, 3];
  var b = ['foo', 'bar'];
  var c = a;
  // a.addAll(b);
  // so that `c` equals to  [1, 2, 3, 'foo', 'bar']
  </code></pre>