-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforindemo.html
More file actions
30 lines (25 loc) · 932 Bytes
/
Copy pathforindemo.html
File metadata and controls
30 lines (25 loc) · 932 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Iterate Over an properties of object Using For in Loop</title>
</head>
<body>
<script>
// An object with some properties
var person = {"name": "Clark", "surname": "Kent", "age": "36"};
// Loop through all the properties in the object
for(var prop in person) {
document.write("<p>" + prop + " = " + person[prop] + "</p>");
}
// An array with some elements
var fruits = ["Apple", "Banana", "Mango", "Orange", "Papaya"];
// Loop through all the elements in the array
for(var i in fruits) {
document.write("<p>" + fruits[i] + "</p>");
}
</script>
</body>
</html>