Created
March 30, 2018 05:25
-
-
Save shoveller/af985127d6429fe23bb293a8dc7a3c12 to your computer and use it in GitHub Desktop.
이터레이터, 이터러블, 이터레이터 리절트의 정의
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 이터러블은 Symbol.iterator 메서드를 가지는 객체 | |
var iterable = { | |
[Symbol.iterator]() { | |
// 이터레이터는 next 메서드를 가지는 객체 | |
const iterator = { | |
// next 메서드는 이터레이터 리절트를 반환하는 함수 | |
next() { | |
return { | |
done: true, | |
value: 'test' | |
}; | |
} | |
}; | |
return iterator; | |
} | |
}; | |
var iteratorResult = iterable[Symbol.iterator]().next(); | |
console.log(iteratorResult); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment