<script> functionCount.counter = 0; function functionCount() { return functionCount.counter++; } for (var i = 0; i < 10; i++) functionCount(); console.log(functionCount.counter); </script>
The code above basically intialize the counter functionCount property and calls the function ten times and then output the counter property directly through the functionCount object, which is ten.
Thanks a lot!
ReplyDelete