Skip to content

Instantly share code, notes, and snippets.

@vivekrk
Created October 19, 2012 15:06
Show Gist options
  • Save vivekrk/3918717 to your computer and use it in GitHub Desktop.
Save vivekrk/3918717 to your computer and use it in GitHub Desktop.
A simple timer sample in javascript
function Timer () {
var i = 1;
var timer = setInterval(function() {
console.log(i);
i++;
if(i > 10) {
clearInterval(timer);
}
}, 1000);
}
var timer = new Timer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment