var test = {
array: [1,2,3,4],
events: function() {
document.getElementById("button").addEventListener("click", this.show);
},
show: function() {
console.log(this.array);
}
}
test.events();
This object, when i click a button, addEventListener inside events method will be called and calls the show method. Then show method displays my array, but it only shows undefined. How to fix it?