お世話になっております。
上記の件なのですが、 constractour 内で timeId を初期化しています。
// constructor 内
this.timeId;
// spin() メソッド内で timeId を発行
this.timeId = setTimeout(() => {
this.spin();
},100);
// constructor 内
this.timeId;
this.stop.addEventListener('click', () => {
clearTimeout(this.timeId);
});
this.timeId は constractour 内ではまだ undifined であるように感じました。
panel インスタンスの spin メソッドは SPIN ボタンの click イベントで動作し、 timeId が発行されるのはわかりましたが、constracutor 内の timeId がそれにより書き変わる仕組みがわかりません。
レキシカルスコープをたどって this.timeId の値が変わっているようにもどうも思えないのですが、どのような挙動で、 clearTimeout(timeId) は this.timeId = setTimeout.... の timeId に変わるのでしょうか?
この回答を見るにはプレミアムプランへの登録が必要です
プレミアムプランとは?