array manipulation code bricks for JavaScript