_markModified(elem) {
    const parent = this[arrayParentSymbol];
    let dirtyPath;

    if (parent) {
      dirtyPath = this[arrayPathSymbol];

      if (arguments.length) {
        dirtyPath = dirtyPath + '.' + elem;
      }

      if (dirtyPath != null && dirtyPath.endsWith('.$')) {
        return this;
      }

      parent.markModified(dirtyPath, arguments.length !== 0 ? elem : parent);
    }

    return this;
  }
Marks this array as modified.

If it bubbles up from an embedded document change, then it takes the following arguments (otherwise, takes 0 arguments)

@param {ArraySubdocument} subdoc the embedded doc that invoked this method on the Array
@param {String} embeddedPath the path which changed in the subdoc
@method _markModified
@api private
@memberOf MongooseArray