Saturday 22 December 2018

JavaScript: for-of loop

for-of loop is used to iterate over iterable objects like String, Array, TypedArray, Map and Set.

HelloWorld.js
var arr = [2, 3, 5, 7, 11, 13];

for (var i of arr) {
   console.log(i); // logs 2, 3, 5, 7
}

Output
2
3
5
7
11
13


Previous                                                 Next                                                 Home

No comments:

Post a Comment