Hi someone, I need a little clarification here.
How does a variable declared within the block of a loop behave? Does it get created just once?
Shouldn’t i get an error on the next iteration that the variable has already been declared/cannot change constant assignment? Or is every loop iteration running in a different scope…
For instance,
//...
for (const arr of myArr) {// myArr contains objects
const product = new Product(arr) // shouldn't i get an error on the next iteration?
//...
}
I have searched the web, but i can’t find an answer. No one is even replying me here either!
Thanks in advance.