Skip to content

Instantly share code, notes, and snippets.

@krabs-github
Last active May 18, 2024 13:01
Show Gist options
  • Save krabs-github/838bbb0f2a39fde51469192a2e80f7ba to your computer and use it in GitHub Desktop.
Save krabs-github/838bbb0f2a39fde51469192a2e80f7ba to your computer and use it in GitHub Desktop.
[JavaScript - Clear All Intervals] JavaScript Clear All Intervals #JavaScript
// 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);
}
@PaulineTrotzer
Copy link

very nice!
it also works without id, (<999), but thank you anyway :)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment