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++)