string.@@iterator
const str = "๋ธ๋ด๋๋๋๋ ์ฝ๋ก๋๋ก ์ ํ๋ธ์ ์คํ๋ผ์ ์ ๋ น ๋ฌด๋ฃ๋ก ํ๋ฆผ";
let iterator = str[Symbol.iterator](); // StringIterator {}
let theChar = iterator.next(); // {value: "๋ธ", done: false}
while(!theChar.done && theChar.value !== ' ') {
console.log(theChar.value);
theChar = iterator.next();
// expected output: "๋ธ"
// "๋ด"
// "๋"
// "๋"
}Syntax
str[Symbol.iterator]Return value
Examples
Using [@@iterator]()
[@@iterator]()Using [@@iterator]() with for..of
[@@iterator]() with for..ofLast updated