Last active
August 6, 2018 01:20
-
-
Save jorben/2d0b224fdfb560e96c08 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
var auto_increase = function(){ | |
var id=0; | |
return function(){return ++id;} | |
}(); | |
// 1 | |
auto_increase(); | |
// 2 | |
auto_increase(); | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment