Skip to content

Instantly share code, notes, and snippets.

@ahoward ahoward/countdown.js
Created Jan 18, 2011

What would you like to do?
capturing deferred state with a closure
// a solution to
var countdown = function(num){
for (var i = 0; i <= num; i += 1) {
(function(i){ setTimeout(function(){ alert(num - i); }, i * 1000); })(i);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.