See the Pen for of by nilgi (@nilgi) on CodePen.
• for (variable of iterable) 반복 가능한 요소 반복
- 문자 반복
const name = "Tistory";
let text = "";
for (const x of name) {
text += x;
}
- 배열 반복
const name2 = ["T", "i", "s", "t", "o", "r", "y"];
let text2 = "";
for (const x2 of name2) {
text2 += x2;
}
- new Set 반복
const name3 = new Set(["T", "i", "s", "t", "o", "r", "y"]);
let text3 = "";
for (const x3 of name3) {
text3 += x3;
}
- map 반복
const pc = new Map([
["cpu", 250000],
["ram", 150000],
["gpu", 500000]
]);
let text4 = "";
for (const x4 of pc) {
text4 += x4 + "<br/>";
}