What is the difference between var and let in Typescript

0 votes

I submitted a question on stack overflow asking how I could stop the putTestQuestionResponses() function from executing IF a previous version was already executing.

The reply was to add in a processing flag which is here on line 2 of this code.

Can you tell me why use a "let" instead of a "var" here?

var promisePutTestQuestion;
let processing = false;

onEnter: ['$interval', 'questionService',
         ($interval, qus: IQuestionService) => {
  promisePutTestQuestion = $interval(() => {
     if (processing)
         return;
     processing = true;
     qus.putTestQuestionResponses()
     .then(() => processing = false)
  }, 5 * 1000);
}],
onExit: ['$interval', ($interval) => {
        $interval.cancel(promisePutTestQuestion);
}]
Aug 3, 2022 in TypeSript by Deepak
• 980 points

edited Mar 4 15 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP