Sunday, 28 October, 2018 UTC


In general: Use `for`...`in` loops to loop over the keys of an _object_. Use `for`...`of` loops to iterate over an _array_ or _string_. The two loop types: and for...of behave differently in javascript. Both loops can be used with Arrays and Strings - but only `for`...`of` loops iterate over the values in order. `for`...`in` loops actually loop over the _enumerable_ properties of an object. For an array, that means that a `for`...`in` loop iterates over the indices of the array - and order is not guaranteed. So use `for`...`of` for arrays or strings, and `for`...`in` for objects.