code: function pickAdUnits(gptSlots) {
        var adUnits = [];
        // traverse backwards (since gptSlots is mutated) to find adUnits in cache and remove non-mapped slots
        for (var i = gptSlots.length - 1; i > -1; i--) {
          const gptSlot = gptSlots[i];
          const elemId = gptSlot.getSlotElementId();
          const adUnit = adUnitsCache[elemId];
  
          if (adUnit) {
            gptSlotCache[elemId] = gptSlot; // store by elementId
            adUnit.sizes = adUnit.sizes || mapGptSlotSizes(gptSlot.getSizes());
            adUnits.push(adUnit);
            gptSlots.splice(i, 1);
          }
        }
  
        return adUnits;
      }
docs: maps gpt slots to adUnits, matches are copied to new array and removed from passed array.