I have something like this
var myArray = [];
myArray.push(someObject);
but then if I delete or splice that array entry I just pushed it also deletes someObject(someObject was passed by reference by pushing, not a clone and I cannot have it be a clone). Is there some way I can:
- just remove the pointer to someObject from myArray without actually deleting someObject
- have it delete the actual key for the object in the array, but not shift all the other keys in the array?
someObject will not get deleted as long as some other variable or object in your javascript has a reference to someObject. If nobody else has a reference to it, then it will be garbage collected (cleaned up by the javascript interpreter) because when nobody has a reference to it, it cannot be used by your code anyway.
Here is a relevant example:
Or done a different way: