title: Understanding David Walsh's once function
body: <p>I came across David Walsh's <code>once</code> function here:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function once(fn, context) { 
      var result;
  
      return function() { 
          if(fn) {
              result = fn.apply(context || this, arguments);
              fn = null;
          }
  
          return result;
      };
  }
  
  // Usage
  var canOnlyFireOnce = once(function() {
      console.log('Fired!');
  });
  
  canOnlyFireOnce(); // "Fired!"
  canOnlyFireOnce(); // nada</code></pre>
  </div>
  </div>
  </p>
  <p>My question is what is the <code>tracker</code> variable here? Doesn't <code>result</code> become <code>null</code> each time <code>canOnlyFireOnce()</code> is fired? What is the purpose of setting the <code>fn</code> to null?</p>