code: function shrinkList(list, newSize) {
      var size = list.length;
      list.length = newSize;
  
      if (size < newSize) {
          do {
              delete list[newSize];
          }
          while (newSize-- < size);
      }
  }
docs: / helper method to shrink the list to lower size and delete upper indexes