Isn't `map.getLayers()` already an array? (I thinks it's an ol.Collection, which is an alias for an array)