I have a function that I attach to a dom object. I want to be able to reference the dom object from within the function, but when I call it from an event, this
isn't equal to the right thing.
var main = document.getElementById('main');
main.testFunction = () => {
console.log('this',this);
}
main.addEventListener('click', main.testFunction);
Instead it's equal to window
. Why is this? How do I reference the object that the method is part of?