· August 19, 2020 · ⋆ JavaScript There are two ways of many using which you can loop over the iterables in JavaScript. While both of the statements can loop over the iterables such as enumerable properties, there are key differences in both which I’ll discuss here. First, the for...in can loop through both Arrays and Objects while the for...of can only loop through Arrays, Map, Set, arguments object.
So, by looking at the differences both of these for statements, it would be safe to tell that the for...in can be used in most of the cases as you’d be using it with both Objects and Arrays and also you can get values of the properties using their keys.