iterator code bricks for JavaScript