I believe this will work in most cases:
```js
function B() {
const obj = new A();
Object.setPrototypeOf(obj, new.target.prototype); // or B.prototype, but if
you derive from B you'll have to do this dance again
// use obj instead of this
return obj;
}
```
Also, in general you should do
```js
Object.setPrototypeOf(B.prototype, A.prototype);
Object.setPrototypeOf(B, A);
```
instead of
```js
B.prototype = Object.create(A.prototype);
```
for slightly better semantics, including class-side inheritance and not
clobbering `.constructor`.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss