So I have a function and I want to be able to create and remove the function with a reference to an anonymous function. I want to do this to provide the ability to create the same function for multiple object. Currently when I create one function and then create another I believe it is overwriting the reference with the newest one and that does not allow me to remove the older reference.
So I want to dynamically create the reference with a variable with something like this.
image.addEventListener("click",
(Highlight + image.alt) = function (){ HighLightClick(this) }, false);
and then remove it like this
TileClicked.removeEventListener("click", (Highlight + TileClicked.alt), false);
Do I have to create a variable for TileClicked or how would one go about this?
Maybe something like: