Skip to content

Instantly share code, notes, and snippets.

@karenpeng
Last active September 20, 2015 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karenpeng/e43e054915082f0f880b to your computer and use it in GitHub Desktop.
Save karenpeng/e43e054915082f0f880b to your computer and use it in GitHub Desktop.
function iterator(arr){
var id = setInterval(
function(){
console.log('haha')
if(arr.length > 0){
console.log(arr.shift())
}else{
clearInterval(id)
}
}, 1000)
}
function iteratorManually(arr){
return function(){
//console.log('haha')
if(arr.length > 0){
console.log(arr.pop())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment