0

When I read code, some people use var but other people use let. I read that the let is the block scope, but if I use the var it's still block scope as you cannot use it outside of the for loop. What is the benefit of using let instead of var in the for loop as the below.

 for (let i = 0; i < action.payload.customers.length; i++)

  • 1
    This question has already been answered. Just try to dig in more using this link. https://stackoverflow.com/questions/762011/whats-the-difference-between-using-let-and-var – amanpurohit May 02 '20 at 07:46
  • "*if I use the `var` it's still block scope as you cannot use it outside of the for loop*" - well, wrong. Just try a loop with `var` and do `console.log(i)` afterwards. – Bergi May 02 '20 at 09:00

0 Answers0