JavaScript: Array Handler