I am wondering why we use const
in javascript for...of
loops. Every example I see using for...of
loops use const
while declaring the variable. For example:
for (const item of array) {
// do something
}
Is there any reason we don't use var
like this?
for (var item of array) {
// do something
}
Thanks