title: What is the difference between var and let in Typescript?
body: <p>I submitted a question on stack overflow asking how I could stop the putTestQuestionResponses() function from executing IF a previous version was already executing. </p>
  
  <p>The reply was to add in a processing flag which is here on line 2 of this code. </p>
  
  <p>Can you tell me why use a "let" instead of a "var" here?</p>
  
  <pre><code>var promisePutTestQuestion;
  let processing = false;
  
  onEnter: ['$interval', 'questionService',
           ($interval, qus: IQuestionService) =&gt; {
    promisePutTestQuestion = $interval(() =&gt; {
       if (processing)
           return;
       processing = true;
       qus.putTestQuestionResponses()
       .then(() =&gt; processing = false)
    }, 5 * 1000);
  }],
  onExit: ['$interval', ($interval) =&gt; {
          $interval.cancel(promisePutTestQuestion);
  }]
  </code></pre>