optimization js arrays