Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
"Hidden closures", EMNIP, is a horror story from the IE6-8 era.
I simplified your code to this and it works:
function Some() {
this.id = Math.floor(Math.random() * 1000);
this.timer = setInterval(() => {
console.log('чем-то гажу в консоль');
}, 1000 * 1);
this.stop = () => {
console.log(this); // тут видно, что контекст действительно правильный
clearInterval(this.timer);
};
}
const some0 = new Some();
setTimeout(() => {
some0.stop();
}, 3000);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question