For loop and for of loop

const person = ['rio',19,'javascript']
for(let i = 0; i < person.length; i++){
             console.log(i);
}
// above code give me index 0,1,2;
but when i apply for of loop,
for(let i of person){
    console.log(i);
}
// output is rio,19,javascript which is values of my array

so,
my question is why only using i is giving me value of my array and not same in case of normal for loop ?
what is the difference between this two ?

this i is a number, you say it should start at 0 with let i = 0 and increase with i++

this i is instead each array element

they are two different loops that have different properties

Hello @ilenia the normal for loop would simply have a syntax like this ~

const person = ['rio',19,'javascript']
for(let i = 0; i < person.length; i++){
             console.log(person[i]);
// So it may mean **"i"** properties of person
}

I guess that can try to help understand more

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.