ES6 - for…of loop


Advertisements

The for…of loop is used to iterate iterables instead of object literals.

Following is the syntax of ‘for…of’ loop.

for (variablename of object){
   statement or block to execute
}

Example

for (let val of[12 , 13 , 123]){
   console.log(val)
}

The following output is displayed on successful execution of the above code.

12
13
123
Advertisements