arr = [
{
id:1
},
{
id:2
}
]
This is an example object structure. I want to delete first object in this array.
delete arr[0];
Resulting structure is
[
{
undefined * 1
},
{
id:2
}
]
I have searched a lot and found that deleting an entire object will lead to dangling pointer problems. But i want resulting array to have only one object after deletion. Is there any other way to achieve this?
EDIT How to do if the object is neither first nor last?