const myFavoriteAuthors = {
	allAuthors : {
		fiction : [
			'Agatha Christie',
			'J. K. Rowling',
			'Dr. Seuss'
		],
		scienceFiction : [
			'Neal Stephenson',
			'Arthur Clarke',
			'Isaac Asimov',
			'Robert Heinlein',
		],
		fantasy : [
			'J. R. R. Tolkien',
			'J. K. Rowling',
			'Terry Pratchett',
		]
	},
}

for(let author of myFavoriteAuthors){
	console.log(author);
}
// TypeError : {} is not iterable

Iterable과 Iterator

const myFavoriteAuthors= {
	allAuthors : {
		...
	},
	getAllAuthors(){
		const authors = [];
		for(const author of this.allAuthors.fiction){
			authors.push(author);
		}
		for(const author of this.allAuthors.scienceFiction) {
			authors.push(author);
		}
		for(const author of this.allAuthors.fantasy){
			authors.push(author);
		}
	
		return authors;
}

A Simple Guide to ES6 Iterators in JavaScript with Examples

iterable은 무엇인가?

iterable은 왜 필요한가?