Hint
Never use for...in on arrays — it includes non-index properties. Use for...of for values.
const arr = [10, 20, 30];
arr.custom = 'extra';
const forIn = [], forOf = [];
for (const k in arr) forIn.push(k);
for (const v of arr) forOf.push(v);
console.log(forIn.join(','));
console.log(forOf.join(','));0,1,2,custom 10,20,30
Explanation: for...in iterates all enumerable keys including custom properties. for...of uses the iterator and only yields the array elements.
Key Insight: Never use for...in on arrays — it includes non-index properties. Use for...of for values.