for...in walks property keys, not values. On an array every key is a string, so i + 1 on index "0" gives "01", not 1.
#javascript #react #typescript

instagram.com/reel/De5sUqKqf…

Oct 25, 2026 · 3:14 AM UTC

1
0
1
43
Replying to @uselessEnggDev
It also visits any extra property on the array and anything enumerable on its prototype, like a method a library added to Array.prototype.
for...of walks the values, and nums.entries() gives a real numeric index. forEach does too. For plain objects, Object.keys returns own keys.
0
0
1
3
RepliesRelevant