I have an array keeping track of javascript objects like this:
var myArray = [];
The objects looks something like this:
Main.prototype.myObject = function (x, y) {
this.x = x;
this.y = y;
this.moveObject = function () {
// Change x, y coordinates
if (someEvent) {
// Delete myself
// deleteObject();
}
};
this.deleteObject = function () {
// Delete code
}
};
And the objects are pushed into the array like this:
myArray.push(new main.myObject(this.x, this.y));
Now, is there a way I can delete a specific instance of the object with this
without knowing it's index within myArray
?
I'd rather keep the for loop clean and do the deleting in the already existing moveObject()
function.