Skip to content

Instantly share code, notes, and snippets.

A self clearing setInterval with a callback
var i = 0;
var timer = setInterval(function(){
// stuff
if(i === 5) {
clearInterval(timer);
console.log('callback'); // callback after some time
}
}, 200);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment