running function in class error
Hey, in the code below, the
example
function won't run and it gives the error "Uncaught TypeError: this.example is not a function"
. I'm a little confused as to why this is happening, could someone point me in the right direction? Thanks in advance.
3 Replies
that's because the
this
changes for the event listener
you need to use an arrow function
and we've explained before, arrow functions don't change the this
valueoh right of course, that didn't even come to mind at the time haha, i thought it was something class related, thanks epic
you're welcome