Last active
September 20, 2015 16:24
-
-
Save karenpeng/e43e054915082f0f880b to your computer and use it in GitHub Desktop.
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 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