I have an array object which has 3 objects. I want to remove all the objects except the first one.
Here is my data which I got from XML:
mrArr[0] = <Data>
<G> "Val" = "5" </G>
</Data>
mrArr[1] = <Data>
<G> "Val" = "6" </G>
</Data>
mrArr[2] = <Data>
<G> "Val" = "7" </G>
</Data>
I have created a loop to try and do this but it is only removing one element. What is wrong with my loop?:
for(var i = 1; i < myArr.length; i++){
myArr[i].remove();
}
It is removing only one element.