js closure

var f = ( function() {
        var a = 1;
        return () => {
            a++;
            console.log(a);
        }
}());

// 2 3 4
f()
f()
f()

  

posted @ 2017-04-28 00:34  ax=null  阅读(96)  评论(0编辑  收藏  举报