In the following code I would like to pas myVar
variable to editNote
function :
class MyNotes {
constructor() {
this.events();
}
events() {
let myVar = 5;
document.getElementById('btn').onclick = this.editNote;
}
editNote() {
}
}
new MyNotes;
I know that if I use
events() {
let myVar = 5;
document.getElementById('btn').onclick = function() {};
}
I would be able to use it directly but for some reason I can't do this. Can someone help me out ?