title: JavaScript: How to add x to an array x times?
body: <p>I imagine this is similar to array padding, but I wonder if it can be simplified at all.</p>
  <pre><code>var arr = [1,2,3],
      x   = 5;
  
  for (var i=0; i&lt;x; i++) {
    arr.push(x);
  }
  
  console.log(arr);
  //=&gt; [1, 2, 3, 5, 5, 5, 5, 5]
  </code></pre>
  <p>Is there any way to do this without using the for loop?</p>
  <hr />
  <p><strong>Update</strong></p>
  <p>Even though there's mover <em>clever</em> solutions, the for-loop seems to be the most performant</p>
  <p><img src="https://i.stack.imgur.com/tuO1u.png" alt="array-fill-2" /> <a href="http://jsperf.com/array-fill-2" rel="noreferrer">Benchmarks on jsperf</a></p>