title: javascript clean array
body: <p>I have four product gallery with the possibility to check the detail of each product from each gallery. Every time the user enter in the detail of any product an array is filled with all the products from that gallery. I should tell this is one single page.</p>
  
  <p>I want to completely delete all the records in the array when the user exits the detail view, because when the user enter again in the detail view the array length increments his size.</p>
  
  <p>I already tried <code>arrayName.length =0;</code> and <code>arrayName.length = []</code> and it deleted the previous data, but his size continue incrementing like this: </p>
  
  <p>1st time detail view is loaded --> arrayName{valA,valB,valC}</p>
  
  <p>2nd time detail view is loaded --> arrayName{,,,val1,val2,val3}</p>
  
  <p>what it's supposed to be in the 2nd time is: arrayName{val1,val2,val3}</p>
  
  <p>Any idea in how I can solve this issue??</p>
  
  <p>Thanks all</p>
  
  <p><strong>The solution</strong></p>
  
  <p>Thanks all guys. It was my problem.</p>
  
  <pre><code>while($rowDetails = mysql_fetch_array($rsDetails)){
  ?&gt;
          &lt;script language="javascript"&gt;
              arrayProd[pos] = &lt;?php echo $rowDetails['RefArticleID']; ?&gt;;
              pos++;
          &lt;/script&gt;
     ... 
  </code></pre>
  
  <p>The array is filled into a while cycle and it increments the pos. At the same time I re-initialize the array I force the pos to be 0 (zero)</p>
  
  <pre><code>arrayProd = [];
  pos =0;
  </code></pre>
  
  <p>Thank you all</p>