-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfor-of.html
36 lines (30 loc) · 1.15 KB
/
for-of.html
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
<!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>For Of</title>
</head>
<body>
<script>
/*
## For Of
● Jika For In digunakan untuk melakukan iterasi property atau index, berbeda dengan For Of, ini digunakan untuk melakukan iterasi terhadap isi value dari iterable object, seperti Array, String dan lain-lain
● For of tidak bisa digunakan untuk melakukan iterasi data di object, karena object bukanlah iterable.
*/
document.writeln(`<p>==========Array Dengan For Of==========</p>`);
// Kode : For Of di Array
const names = ["Fauzan Ahmad", "Yono Kurniawan", "Wahyu Inna"];
for (const name of names) {
document.writeln(`<p>${name}</p>`);
}
document.writeln(`<p>==========String Dengan For Of==========</p>`);
// Kode : For Of di String
const name = "Fauzan Ahmad";
for (const char of name) {
document.writeln(`<p>${char}</p>`);
}
</script>
</body>
</html>