JSFiddle - React, Tailwind, and code Playground

JavaScript

(function (parent)  {
  (function (parent) {
    let instances = {};

    this.getPrivateInstance = function (c) {
      return instances[c];
    };

    this.setPrivateInstance = function (c, value) {
      instances[c] = value;
    };

    this.deleteFromMemory = function (c) {
      delete instances[c];
    }	
  } (this));

  parent.Class = class {
    constructor(name) {
      setPrivateInstance(this, {
        name: name
      });
    }

    logName() {
      console.log(getPrivateInstance(this).name);
    }

    deleteFromMemory() {
      deleteFromMemory(this);
    }
  };
})(window);

c = new Class("test");

c.logName(); // "test"

console.log(c.name); // undefined

c = c.deleteFromMemory();