I’m trying to access a variable in a constructor from a static method but it looks as if the only way I can get access to it is through a constructor in th static method which don’t want to do.
class voting {
constructor() {
this.totalVote = document.querySelectorAll(".likes-button span")
}
static addVote() {
this.totalVote.forEach(vote => {
console.log(vote.innerText)
});
}
}
console.log(voting.addVote());
I tried it without the using parameter and it worked. But I don’t want to access it using an agument. Is it possible?