Identifies the element type of the iterator
A synchronous function that accepts up to three arguments. iterForOf calls the
callbackfn function one time for each element returned by the iterator.
OptionalthisArg: any
An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, null or undefined the iterator will be used as the this value.
If Symbols are NOT supported then the iterable MUST be using the same polyFill for the well know symbols, if you are targetting a mixed environment you SHOULD either
synchronous function.
iterForOf does not wait for promises. Make sure you are aware of the implications while using
promises (or async functions) as forEach callback.
Calls the provided
callbackFnfunction once for each element in the iterator or iterator returned by the iterable and processed in the same order as returned by the iterator. As with thearrForEach()you CAN stop / break the iteration by returning -1 from thecallbackFnfunction.The order of processing is not reset if you add or remove elements to the iterator, the actual behavior will depend on the iterator imeplementation.
Like
for...of:[Symbol.iterator](), even when it is also an iterator (has anext()function), and only an iterator which is not iterable is used as-is. The built-in iterators and generators return themselves, while an object such as a jQuery collection (which has anext()function that is not an iterator function) is processed using its iterator. On a runtime withoutSymbol.iterator(eg. IE), where an array isn't iterable, an array (which isn't also an iterator) is processed by its indexes (since 0.20.0), like the native array iterator its values are read as they are iterated (so a value added by thecallbackFnis also processed). Likewise aMap(its[key, value]entries) orSet(its values) which isn't iterable (eg. on IE 11, which has no iterator functions) is processed (since 0.20.0) using itsforEach(), as a copy of its entries / values when processing starts (so a value added by thecallbackFnis not processed).callbackFnreturns -1 or throws, the iterator is closed by calling itsreturn()function (if any), so a generator'sfinallyblock is run. The error thrown by thecallbackFnis then re-thrown (rather than any error thrown byreturn()). The iterator is not closed when the iterator itself throws.TypeErroris thrown when[Symbol.iterator]()doesn't return an iterator, whennext()returns a value which is not an object, or whenreturn()returns a value which is not an object after thecallbackFnreturns -1.