Iterable and Iterator

An Iterable is an object with a [Symbol.iterator] / @@iterator method which returns an Iterator. String, Array, TypedArray, Map, Set, argumentsarguments arguments ,, , and a few DOM structuresare iterablesiterables iterables . WeakSet and WeakMap are not iterables (The values returned by entries(), keys(), and values() from Objects, Arrays, TypedArrays, Sets, and Maps are also iterables.)Iterables can be used: - as the RHS of a destructuring assignment - with the spread operatorspread operator spread operator ... in an expression - in for-of loopsfor-of loops for-of loops - as the argument to Array.from(), Set(),

WeakSet(), Map(), WeakMap() - as the argument to Promise.all() and

Promise.race() - in generators to yield*yield* yield* all items

An Iterator is an object with a special next() method that returns an object with two properties -- value and done. To iterate over the values of an Iterator, I, use I.next().value. Consider using an iterator over a generic for or while loop.