-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.js
More file actions
71 lines (66 loc) · 1.37 KB
/
loops.js
File metadata and controls
71 lines (66 loc) · 1.37 KB
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
64
65
66
67
68
69
70
71
var brands = ['kingfisher','signature','royal stag','vat69'];
for(var element of brands){
console.log('value= ',element); // for of loop
}
console.log('=======================================')
for(var index in brands)
{
console.log('Brand', brands[index]); // for in loop
break;
}
console.log('========================================')
var persons = {
name : 'sunny leone',
age : 33,
color : 'white'
}
for(var key in persons){
console.log('value = ', persons[key])
}
console.log('============================');
// for-Each method of array
var movies = ['sholay','titanic','hera pheri','sahoo']
movies.forEach(function(value,index){
console.log('Movies = ', value);
});
console.log('===================================');
//objects inside array
var items=[{
item : 'bangles',
id : 1,
price : 500
},
{
item : 'bags',
id : 2,
price : 1000
},
{
item : 'watches',
id : 3,
price : 5000
},
{
item : 'bike',
id : 4,
price : 1000000
}]
items.forEach(function(value,index){
console.log('Items = ',value);
console.log('Index of item = ',index)
})
var number = [10,20,,30,40,]
for (var i= 0; i<number.length; i++)
{
console.log(number[i])
number[2]=90;
}
console.log('============================')
for(var i in number)
{
console.log(number[i])
}
for(var t of number)
{
console.log(number[i])
}