Created
March 3, 2011 20:17
-
-
Save jordandobson/853452 to your computer and use it in GitHub Desktop.
create closure
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
(function(countdown, container){ | |
var index; | |
function log(){ | |
console.log(index); | |
} | |
function iterate(){ | |
log(); | |
if(index>1) setTimeout(iterate, 1000); | |
index--; | |
} | |
container[countdown] = function(){ | |
index = 10; | |
iterate(); | |
} | |
})('countdown', this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment