title: Javascript add same element N times in an Array
body: <p>Suppose I have map like this:</p>
  
  <pre><code>var map = {"a" : 100, "b" : 200, "c": 700};
  </code></pre>
  
  <p>And I want an Array consisting of "a" 100 times, "b" 200 times and "c" 700 times:</p>
  
  <pre><code>map_array = [a, a, a, a, ... a, b, b, b, ... b, c, c, c, ... c]
  </code></pre>
  
  <p>Simple solution is to just loop the frequency times and push in the array:</p>
  
  <pre><code>var map_array = []
  for(key in map)
  {
      for(var i=1; i &lt;= map[key] ; i++)
      {
         map_array.push(key)
      }
  }
  </code></pre>
  
  <p>But this will obviously take time to processes with large data, can we rework the above function to make it more efficient?</p>