Question : what is diffarent between for loop of and in
Answered by : md-zubair-alam-roktim-xs6oergwi2z7
let arr = ['el1', 'el2', 'el3'];
arr.addedProp = 'arrProp';
// elKey are the property keys
for (let elKey in arr) { console.log(elKey);
}
// elValue are the property values
for (let elValue of arr) { console.log(elValue)
} Run code snippetHide results
Source : https://stackoverflow.com/questions/29285897/what-is-the-difference-between-for-in-and-for-of-statements | Last Update : Wed, 17 Aug 22