3 ms·
"This works because functions create an own scope for the variable" It works because it's a brand new variable. JavaScript is a pass by value language, and the
by city41 13y ago
"This works because functions create an own scope for the variable"
It works because it's a brand new variable. JavaScript is a pass by value language, and the i inside the function is a different chunk of memory than the i from the loop
- christian_fei 13y agoupdated. thanks for the clarification