Since you're running this all on an environment that actually supports real ES6 classes, you may be able to achieve what you're looking for. What you'll need to do is to change your subclass logic to be
var ProtoChildFromClassParent = function(a) {
const _this = Reflect.construct(ClassParent, [a], new.target);
return _this;
}
Object.setPrototypeOf(ProtoChildFromClassParent, ClassParent);
Object.setPrototypeOf(ProtoChildFromClassParent.prototype, ClassParent.prototype);
This is predicated on Reflect.construct
being available, so it will not work on an older ES5 environment, but then neither would ES6 class syntax either. It's also important that new.target
be available. As long as both are available, this is very close to replicating the behavior you'd get from using actual class syntax. That said, immediately the question would be why you're not just doing
class ProtoChildFromClassParent extends ClassParent {}
so whether this is useful or not really depends on what's stopping you from doing that to begin with.