Last active
May 18, 2024 13:01
-
-
Save krabs-github/838bbb0f2a39fde51469192a2e80f7ba to your computer and use it in GitHub Desktop.
[JavaScript - Clear All Intervals] JavaScript Clear All Intervals #JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get a reference to the last interval + 1 | |
const interval_id = window.setInterval(function(){}, Number.MAX_SAFE_INTEGER); | |
// Clear any timeout/interval up to that id | |
for (let i = 1; i < interval_id; i++) { | |
window.clearInterval(i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very nice!
it also works without id, (<999), but thank you anyway :)!