-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.html
More file actions
29 lines (27 loc) · 752 Bytes
/
Copy pathloop.html
File metadata and controls
29 lines (27 loc) · 752 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>loop</title>
</head>
<body>
<h1 id="hw">Hello duniya</h1>
<script>
var ar = [2,4,5,7,9,"world", {a:"Hello"}]
for(var i in ar){
console.log(ar[i]); //print with index
}
for(var i of ar){
console.log(i); //print without index
}
console.log(ar[6].a) //printing an elememt of object of array
ar[6].b = "kunal" //adding an element in object
console.log(ar[6])
for(var i=0;i<10;i++){
let hw = document.getElementById("hw")
console.log(hw)
}
</script>
</body>
</html>