title: JavaScript: Sending comma separated string of parameters to a javascript function
body: <p>I am having a function in javascript as </p>
  
  <pre><code>function add(v1,v2){
  
  var add=v1+v2;
  
  }
  </code></pre>
  
  <p>Now I am calling this function as below -</p>
  
  <pre><code>write.out(var param="1,2";);
  
  write.out(window[add](param););
  </code></pre>
  
  <p>Using the above call, it's not working. What it does is it gives the complete string "1,2" as value to the first param(v1) of the function.</p>
  
  <p>Its working if I call the function in following way -</p>
  
  <pre><code>write.out(var param1="1";);
  
  write.out(var param2="2";);
  
  write.out(window[add](param1,param2););
  </code></pre>
  
  <p>I want to achieve it using the first way where i can send the parameters as a comma separated string of parameters.</p>
  
  <p>Can some one help me out how this can be done...</p>
  
  <p>Thanks!!!</p>