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
/* | |
Calling Counter with (a possibly `undefined`) `init` | |
returns a function that closes over `counter` and | |
increments it every time it's called. | |
*/ | |
function Counter(init) { | |
var counter = init || 1; | |
return function() { | |
var current = counter; | |
counter += 1; |
NewerOlder