What is the purpose of the for...in loop in JavaScript?
The for...in loop in JavaScript is designed to iterate over the enumerable properties of an object. For example, for(let key in obj) { console.log(key, obj[key]); } will iterate over each enumerable property key in the object obj. While for...in can be used with arrays (since arrays are objects in JavaScript), it's generally not recommended because it also iterates over any other enumerable properties of the array, not just the numeric indices. For arrays, it's better to use a standard for loop, Array.forEach(), or the newer for...of loop.