Created
February 2, 2013 12:03
-
-
Save takaheraw/4697019 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var agg = (function(){ | |
var index = 0, | |
data = [1, 2, 3, 4, 5], | |
length = data.length; | |
return { | |
next: function(){ | |
var element; | |
if(!this.hasNext()){ | |
return null; | |
} | |
element = data[index]; | |
index = index + 1; | |
return element; | |
}, | |
hasNext: function(){ | |
return index < length; | |
} | |
} | |
}()); | |
while(agg.hasNext()){ | |
console.log(agg.next()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment