title: Calling function with a varying number of arguments (JS)
body: <p>Anyone knows how to do it (using ES5)? Hello.</p>
  
  <p>Found similar questions in the C++ and C sections, but not in the Javascript one.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var array = [1, 2, 3, 4, 5];
   
  //single argument
  console.log(array[0]);
   
  //dynamic arguments
  var item;
  for (var i in array) {
   item = array[i];
   console.log("test", item);
   //same as
   //console.log("test", 0);
   //console.log("test", 1);
   //...
  }
  
  //Objective: console.log("test", 1, 2, 3, 4, 5);
  /*var obj = {};
  for (var key in array) {
   obj[key] = array[key];
  }
  console.log("test", obj[0], obj[1], obj[2], obj[3], obj[4]);
  */
  console.log("test", array[0], array[1], array[2], array[3], array[4]);
  //need to know the no. of items</code></pre>
  </div>
  </div>
  </p>