If we are not able to reassign the value in the variable that is defined with the const
then why it is changing his value every time, when the loop gets executed
const array = [1,2,3,4] ;
for (let index = 0; index < array.length; index++) {
const element = array[index];
console.log(element);
}
If we are not able to reassign the value in the variable that is defined with the const
then why it is changing his value every time, when the loop gets executed
const array = [1,2,3,4] ;
for (let index = 0; index < array.length; index++) {
const element = array[index];
console.log(element);
}
answer is
you are storing the array[index] in element
you are not re-declaring but you are updating the value of element