Skip to content

Instantly share code, notes, and snippets.

@jorben
Last active August 6, 2018 01:20
Show Gist options
  • Save jorben/2d0b224fdfb560e96c08 to your computer and use it in GitHub Desktop.
Save jorben/2d0b224fdfb560e96c08 to your computer and use it in GitHub Desktop.
闭包实现 自增计数
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