title: Set Value of Variable on first instance of function running
body: <p>For example I have a variable which should increment every time the function is run. I want the variable to initially be given the value of 0, but then increase by 1 every time the function is called. I do not want to give the variable global scope, however obviously if I declare it within the function it is going to be reset to 0 every time it is called.
  Is there a simple and efficient way to to do this in Javascript?</p>
  
  <p>My Javascript:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function myFunction(){
   var i=0;
   //Body of function
   i++;
  }</code></pre>
  </div>
  </div>
  </p>