I have an Array like
var myArray = new Array;
I have to push some elements to array in such a way that the elements will be replaced with same index
.
Example :
myArray.push(1);
myArray.push(2);
myArray.push(3);
so now
myArray[0] = 1
myArray[1] = 2
now when i will push element 3
then
myArray[0]
will be replaced with 3
and myArray[1]
will be replaced with 1
and the element 2
will be removed.
It will continue according to the number of elements pushed...
Can any body help me with this requirement...