for…in yields enumerable string property keys, including inherited keys. for…of consumes an iterable’s values, such as array elements. Plain objects are not iterable by default. Use Object.entries for their own enumerable string-keyed entries, or for…of for array values.
Follow-up Interview Question · How do a sparse slot and an extra named array property behave under each loop?