for..of in javascript
for..of loop retrieves item or character one after the another from an array or string.
Initialization will always start at first position in an array.
Loop count will be determined by the array size.
Syntax
Example Explanation
- In loop, first value(10) in the array is retrieved and stored in temp variable(var temp of ar).
- Next that value stored in temp variable will be displayed(alert(temp);).
- Then the second value(20) will be automatically retrieved and displayed.
- The above steps continue till all the array values are retrieved and displayed.