ES5와 ES6의 리스트 순회 차이 for...of를 통해 이터러블을 순회할 수 있다. // ES5 const list = [1,2,3]; for(let i = 0; i < list.lenght; i++) { console.log(list[i]); // 1 2 3 }; const str = 'abc'; for(let i = 0; i < list.lenght; i++) { console.log(str[i]); // 1 2 3 }; // ES6 for (const a of list) { console.log(a); } for (const a of str) { console.log(a); } 이터러블 / 이터레이터 프로토콜 for...of 문을 통해 Array, Set, Map 등 이터러블을 순회할 수 있다. 기존의 for...i++ 문은 Set과 Map을 순회하기가 어려웠다. // Array const arr = [1,2,3]; for (const a of arr) console.log...
#
iterable
#
iterator
#
JavaScript
#
리스트순회
#
이터러블
#
이터러블순회
#
이터레이터
#
전개연산자