Lazy implementation of JavaScript's array iteration functions