-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9) JS FOR loop types.js
More file actions
63 lines (46 loc) · 1015 Bytes
/
9) JS FOR loop types.js
File metadata and controls
63 lines (46 loc) · 1015 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//for in
//for of
//for each
var arr=[10,20,true,"Sripathy",96.10,false];
//for in
for(var i in arr) //takes only index
console.log(i);
console.log();//just space gap
for(var i in arr) //takes only index
console.log("value present in ",i," is ",arr[i]);
console.log();
console.log();//think TOMMY think?
//for of
//used to access elements directly
for(var i of arr)
console.log("Direct value ",i);
console.log();
//for each
//used to access elements directly
arr.forEach(value=>{
console.log(value);
})
console.log();
//Objects with keys and for loop
var student={
"Name":"Sri",
"Age":20,
"rollno":"21CDR050",
}
for(var ele in student)
{
console.log(ele);
}
console.log();
//NOW your test your MINDD...
//what is the output ??
var student={
"Name":"Sri",
"Age":20,
"rollno":"21CDR050",
}
for(var ele in student)
{
console.log(student[ele]);
}
//that's it the For loop types..............