Count functions calls with JavaScript

后端 未结 4 349
傲寒
傲寒 2021-01-21 12:16

For example: I have a lot of functions and use them many times. I need to count calls for each function. What is the best practice to make it?

At first i thought i need

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-21 12:41

    var count = 0;
    
    function myfunction()
    {
        count++;
        alert( "Function called " + count);
    }
    
    
    myfunction();
    myfunction();
    

    http://jsfiddle.net/xsdzpmwm/3/

提交回复
热议问题