For Of

  • Used to iterate iterable objects

  • Loop values instead of keys

  • You can use break, continue in for of loop

  • won't loop over prototype like for in

Loop array

var arr = [1,2];

for(let val of arr){
    console.log(val);
}
// output
1
2

Iterare over arguments ( without converting it to array )

// else you might have done Array.from(arguments).forEach()
function getVal(){
    for(let val of argumants){
        console.log(val);
    }
}

Loop over dom nodes without converting it to array

Loop with index

Obeject literal not iterable

Iterate Set

Iterate Map

Last updated

Was this helpful?