In php we can do this:
$classInstance = new MyClass();
$className = get_class_name($classInstance);
$newInstance = new $className; 
How can I do the same in javascript?
I tried with Object.creat and Object.assign, however when calling methods from the new class, the old was was still being referenced:
  const newInstance = Object.assign(
    Object.create(
      Object.getPrototypeOf(oldInstace)
    ),
    oldInstance
  );
  newInstance.method(); // "this" still referencing oldInstance
