ウェブページのコンテキストで以下のスクリプトを実行し、ページを一度クリックしてください。1秒後にメッセージがポップアップします。1秒間に複数回ページをクリックしても、アラートは一度しか表示されません。 const alarm = { remind(aMessage) { alert(aMessage); this.timeoutID = undefined; }, setup() { if (typeof this.timeoutID === "number") { this.cancel(); } this.timeoutID = setTimeout( (msg) => { this.remind(msg); }, 1000, "Wake up!", ); }, cancel() { clearTimeout(this.timeoutID); }, }; window.addEvent
![clearTimeout() - Web API | MDN](https://cdn-ak-scissors.b.st-hatena.com/image/square/aa767575b4232d312d2c5de428f0bf0955805e26/height=288;version=1;width=512/https%3A%2F%2Fdeveloper.mozilla.org%2Fmdn-social-share.cd6c4a5a.png)