Iterator
Container
Iterator
Container
Iterator
Container
Iterator
Container
Iterator
Container
Iterator
Container
Iterator
Container
Iterator
Container
Iterator
Container
logic <=> container
decoupled
//normal approach
let myArray = [1, 2, 3, 4, 5];
for ( let i = 0 ; i < myArray.length ; i++ ) {
console.log( myArray[i] );
}
//normal approach
let myArray = [1, 2, 3, 4, 5];
for ( let i = 0 ; i < myArray.length ; i++ ) {
console.log( myArray[i] );
}
//iterator approach
let myArray = new IterableList ( 1, 2, 3, 4, 5 );
let iterator = myArray.iterator();
while( iterator.hasNext( ) ){
console.log( iterator.next( ) );
}