for - of

Added in ES 2015.
This can be used instead of for - in loops

for (variable of iterable) { 

Iterating an Object

This loop allows us to iterate over iterable objects.

Iterating an Array

This loop allows us to iterate over arrays.
Arrays > Loops

Iterating over a String

const myString = 'better';  
for (const value of myString) {

Iterating a Map

Arrays > Collections > Maps

Iterating a Set

Arrays > Collections > Sets

Iterating an Object "for - each - in" (Deprecated)

This has been deprecated and replaced with for-of
This should not be used to iterate over object values

var myObject = {prop1: 5, prop2: 13, prop3: 8}; 

for each (var item in myObject) {

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext