JavaScript: Array cylce