title: How to remove and push array elements in Jquery?
body: <p>I have an array element, for example </p>
  
  <pre><code>var a=[1,2,3,4,5];
  </code></pre>
  
  <p>I need to loop into this array and get only the last element of an array. I want to add a some elements into same element by deleting the past element. </p>
  
  <p>example scenarios</p>
  
  <pre><code>for(i=0;i&lt;a.length;i++)
  {
  
  if(a[i]!=a.length){
  //getting last element of an array
  
  alert(a[i]); // output equal to 5.
  </code></pre>
  
  <p>I need to  delete this array elements, and I need to add new element like this</p>
  
  <pre><code>a[i]=[11,22,33,44,55];
  
  //then this a[i] should again goto  for loop and checking the condition and I need to get output as 55. 
  
  }
  
  }
  
  }
  </code></pre>
  
  <p>Can u please Help me for this scenarios..
   my problem is i need to get a last element of an array,(its working fine). after that i need to empty the array, then only i need to add. this scenario should repeat for n times, </p>