[javascript]setIntervalのプロセスを停止する方法
clearIntervalを使用する
const intervalId = setInterval(function() {
console.log("Interval is running...");
}, 1000); // This interval will run every 1 second (1000 milliseconds)
setTimeout(function() {
clearInterval(intervalId); // This will stop the interval timer
console.log("Interval is now disabled.");
}, 5000); // This will stop the interval after 5 seconds (5000 milliseconds)