3 ms·
Yep, and each iteration replaces the previous one. Think of each iteration as its own scope. If you want to persist a const across iterations, you'd define it
by steve_adams_86 6y ago
Yep, and each iteration replaces the previous one. Think of each iteration as its own scope.
If you want to persist a const across iterations, you'd define it in a scope above it. You could also modify a let variable defined a parent scope. Personally I avoid doing that, but it's possible. Anything defined in an iteration though, I'd consider disposable unless it's a reference to and outer scope variable.
Someone correct me if I'm wrong!
- wcarss 6y agoI think you're right! And the value of doing it this way is that you cannot re-assign these names within the scope: they are const on each iteration of the loop.