title: Javascript - Send an array of arrays to a function
body: <p>I have a function which return a list from  arrays. I call the function with an array of these arrays.</p>
  
  <p>Here is the code :
      
      </p>
  
  <pre><code>&lt;body&gt;
  
  &lt;script src="https://code.jquery.com/jquery-1.11.1.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  
  
  
      jQuery(document).ready(function($) {
  
  
          function getList(liste) {
              var control = ['resize', 'scroll', 'zoom', 'focus', 'blur', 'select', 'change', 'submit', 'reset'],
                      keyboard= ['keydown', 'keyup', 'keypress', 'input'],
                      mouse = ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mousemove', 'mouseout', 'mousewheel', 'wheel'],
                      all = control.concat(keyboard, mouse);
  
  
              console.log(liste);
  
              tab = [];
  
              for (var i=0; i &lt; liste.length; i++) {
                      tab = tab.concat(liste[i]);
  
              }
              console.log('Array : ' + tab);
  
              return tab;
          } // End getList()
  
      console.log('Function return : ' + getList(['control', 'keyboard']));
  
      });
  
  
  
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>if i do a getList([control, keyboard]); I have an error because the browser don't know control or keyboard. Logic because they're local to the function. I i send these values with a ' the function return the parameters list in a string way.</p>
  
  <p>I can't put the arrays definitions in global because I call this function from many places in many scripts.</p>
  
  <p>In my example i should have</p>
  
  <pre><code>['resize', 'scroll', 'zoom', 'focus', 'blur', 'select', 'change', 'submit', 'reset','keydown', 'keyup', 'keypress', 'input']
  </code></pre>