class A { launch() { let step = this.step++; let coords = this.stops[0][step]; Tutor.moveRect(coords); Tutor.next(); } static next() { let next = document.querySelectorAll(".next")[0]; next.addEventListener("click", launch); // * } } The next () method internally calls the launch () method (should call), but this does not happen, and I get an error:
Uncaught ReferenceError: launch is not defined
Tried to do it too?
static next() { let next = document.querySelectorAll(".next")[0]; next.addEventListener("click", function() { launch(); }); } But it does not work.
And I tried it like this:
class A { static launch() { let step = this.step++; let coords = this.stops[0][step]; Tutor.moveRect(coords); Tutor.next(); } static next() { let next = document.querySelectorAll(".next")[0]; next.addEventListener("click", function() { A.launch(); }); } } But it does not suit me.
How to get around this behavior?
About possible duplicates.
Here , for example, a different syntax is used. So the answer to that question does not suit me.
(new A()).launch()- etki