Почему вы летает ошибка Uncaught TypeError: xxx is not a function
Я пытаюсь вызвать метод tes2 из test1 но всегда получаю ошибку Uncaught TypeError: this.test2 is not a function at HTMLDivElement.<anonymous>
class bookSelector {
buttons = document.getElementsByClassName('sorting_point');
test1() {
for (const button of this.buttons) {
button.addEventListener('click', function() {
this.test2();
});
}
}
test2() {
alert("qweqeqweqwq");
}
}