I am facing a problem. When I try to call value of variable of the class. Would everyone mind help me? the following is my issue:
- I wrote an event for a Node, and call var that I have defined before
class Testing{
constructor(name){
this._name = name;
}
show(){
var node;
node = document.getElementById('offer_sections_box');
node.addEventListener('click',function(){
console.log(this._name);
console.log('hihi');
})
}
}
a = new Testing('Nguyen Thanh Vuong');
a.show();
- Unfortunately, I could not get the value of Name, the result return undefined. undefined
Would someone mind explain to me the reason, and give me some advice to handling this problem. Thank you so much