Function count calls

后端 未结 5 1723
轻奢々
轻奢々 2021-01-12 22:24

I\'m a beginner with JavaScript so please be patient =)

I am trying to write a function that counts the number of times it is called. What I have so far is a functi

5条回答
  •  庸人自扰
    2021-01-12 23:16

    var increment = function() {
        var i = 0;
        return function() { return i += 1; };
    };
    
    var ob = increment();
    

提交回复
热议问题