title: How to fetch/ get all the arguments of the function?
body: <p>With JavaScript we have arguments property that lets us get the arguments of the function. I generally do it this way</p>
  
  <pre><code>function sum(){
      var agumentCount = arguments.length;
      var count =0;
      var sumArguments = [];
  
      // Fetching the arguments
      while(count != agumentCount){
          sumArguments.push(arguments[count]);
          count++;
      }
  
      // function logic -- neglect this
      var data = 0;
      for(var i=0; i&lt;sumArguments.length;i++){
          data+=sumArguments[i];
      }
      return data;
  }
  </code></pre>
  
  <p>// Calling the function</p>
  
  <pre><code>sum(2,3);
  sum(9,15,65,458748);
  sum();
  sum(1);
  </code></pre>
  
  <p>Is there better way of fetching the arguments, as this takes O(n), where n is the number of arguments for the function.</p>