Basically this is my object:
Object
data:Array[4]
0:Object
1:Object
2:Object
3:Object
length:4
__proto__:Array[0]
__proto__:Object
I want to delete 3rd object i,e 2:object
This is what i am doing.
for(var arr in mainObj){
var index = Object.keys(mainObj).indexOf(arr);
if(index == 2)
{
delete mainObj[arr];
}
}
This is not working. How to achieve this. Finally i should get.
Object
data:Array[3]
0:Object
1:Object
2:Object
length:3
__proto__:Array[0]
__proto__:Object