-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path34 for of loop.js
More file actions
40 lines (22 loc) · 769 Bytes
/
34 for of loop.js
File metadata and controls
40 lines (22 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
The For Of Loop
The JavaScript for of statement loops through the values of an iterable object.
It lets you loop over iterable data structures such as Arrays, Strings, Maps, NodeLists, and more:
Syntax
for (variable of iterable) {
// code block to be executed
}
variable - For every iteration the value of the next property is assigned to the variable. Variable can be declared with const, let, or var.
iterable - An object that has iterable properties.
*/
// ******************Looping over an Array**************
const cars = ["BMW", "Volvo", "Mini"];
for (let x of cars) {
// console.log(x);
}
// ***************Looping over a String***************
let language = "JavaScript";
let text = "";
for (let x of language) {
//console.log(x);
}