title: Repeat an array with multiple elements multiple times in JavaScript
body: <p>In JavaScript, how can I repeat an array which contains multiple elements, in a concise manner?</p>
  
  <p>In Ruby, you could do</p>
  
  <pre><code>irb(main):001:0&gt; ["a", "b", "c"] * 3
  =&gt; ["a", "b", "c", "a", "b", "c", "a", "b", "c"]
  </code></pre>
  
  <p>I looked up the lodash library, and didn't find anything that was directly applicable. <a href="https://github.com/lodash/lodash/issues/1436" rel="noreferrer">Feature request: repeat arrays.</a> is a feature request for adding it to lodash, and the best workaround given there is</p>
  
  <pre><code>const arrayToRepeat = [1, 2, 3];
  const numberOfRepeats = 3;
  const repeatedArray = _.flatten(_.times(numberOfRepeats, _.constant(arrayToRepeat)));
  </code></pre>
  
  <p>The questions <a href="https://stackoverflow.com/questions/1295584/most-efficient-way-to-create-a-zero-filled-javascript-array">Most efficient way to create a zero filled JavaScript array?</a> and <a href="https://stackoverflow.com/questions/12503146/create-an-array-with-same-element-repeated-multiple-times">Create an array with same element repeated multiple times</a> focus on repeating just a single element multiple times, whereas I want to repeat an array which has multiple elements.</p>
  
  <p>Using reasonably well-maintained libraries is acceptable.</p>