I am playing around with ES6 and get stuck in "this". I have button and I want when a user click on button the text of button should be updated as "Passed".
HTML
<button type='button'>Click Me</button>
JS
class Test {
constructor(){
this.result = "Passed";
}
run() {
alert('clicked');
this.textContent = test.result;
}
btnClik() {
document.querySelector('button').addEventListener('click', this.run ,false)
}
}
let obj = new Test();
obj.btnClik();
You may see it in action: JSfiddle link