I'm doing some experiments with class and weirdly in this special case, setInterval is only called once if I pass test.method1() and I get error if I pass test.method1, why ?
class Test {
constructor() {
this.counter = 0;
(async () => {
this.test();
}
)();
}
test() {
this.method1();
}
method1() {
let value;
value = this.method2();
console.log(this.counter);
}
method2() {
this.counter++;
return this.counter;
}
}
let test = new Test();
let id = setInterval(test.method1(), 1000);