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:
var x = {};
x.foo = 3;
var y = [];
y.push(x);
y.length = 0; // removes all items from y
console.log(x); // x still exists because there's a reference to it in the x variable
x = 0; // replace the one reference to x
// the former object x will now be deleted because
// nobody has a reference to it any more
Or done a different way:
var x = {};
x.foo = 3;
var y = [];
y.push(x); // store reference to x in the y array
x = 0; // replaces the reference in x with a simple number
console.log(y[0]); // The object that was in x still exists because
// there's a reference to it in the y array
y.length = 0; // clear out the y array
// the former object x will now be deleted because
// nobody has a reference to it any more
.splice
deletessomeObject
?.splice()
removes elements from an array but where those elements were objects it doesn't delete the actual objects - but you'd need to have some other reference to those objects to continue to use them. So if thesomeObject
variable still refers to the object you can still use that after removing the reference from the array..splice()
actually returns an array of the deleted items, so...$("#ele").clone()