javascript – How to optimize loops and apply reducer for array?

I have the follwing code:

  let drawRegistryPolygonsId = ();
  registryLayers.forEach((r) => {
    r.forEach((_r) => {
      const drawSourceId = this.MapLibraryService.interactiveMap.getSourceId();
      drawRegistryPolygonsId.push(drawSourceId);
      this.drawPolygon(_r, drawSourceId);
    });
  });

How to apply reducer for drawRegistryPolygonsId and optimize these loops?