I'm trying to call a this
method in my class. When I do that, I get an error saying:
Uncaught TypeError: this.logMe is not a function
I tried removing this
but it still had an error. Here's my code:
function Logger() {
this.logMe = function() {
console.log('Log a Message');
};
window.addEventListener('click', function() {
this.logMe();
});
}
var hello = new Logger();
What am I doing wrong and how can I fix it?