With an anonymous class mixin JavaScript allows to extends a class with a variable parameter.

const unsubscribeMixin = baseClass => class extends baseClass {
  #subscriptions = [];

  set subscription(subscription) {
    this.#subscriptions.push(subscription);
  }

  unsubscribe() {
    this.#subscriptions.forEach(subscription => subscription.unsubscribe());
    this.#subscriptions.length = 0;
  }
};

class BaseComponent {
  unsubscribe() {
  }
}

class ProductComponent extends unsubscribeMixin(BaseComponent) {
  constructor() {
    // Without calling super() the "this"-object will be undefined.
    super();

    const fakeSubscription = {
      unsubscribe: () => { },
    };

    this.subscription = fakeSubscription;
  }
}

const productComponent = new ProductComponent();
productComponent.unsubscribe();

Nice to now about JavaScript classes

A class in JavaScript is just syntactic sugar. Classes are still regular functions under the hood.
The follow code is generated when using the TypeScript transpiler which illustrates the point.

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();

var BaseComponent = /** @class */ (function () {
    function BaseComponent() {
    }
    BaseComponent.prototype.unsubscribe = function () {
    };
    return BaseComponent;
}());

var ProductComponent = /** @class */ (function (_super) {
    __extends(ProductComponent, _super);
    function ProductComponent() {
        return _super.call(this) || this;
    }
    return ProductComponent;
}(BaseComponent));

Classes in JavaScript force you to "call" the "class function" with the new keyword.

// TypeError: Class constructor ProductComponent cannot be invoked without 'new'
const productComponent = ProductComponent();

Source: JavaScript/TypeScript playground