1

There is a big red warning label on the Mozilla page for Object.setPrototypeOf and I've been trying to understand what exactly the optimization issues with changing the prototype are, but I don't think I have, so I'll come right out and ask: Will the code below cause performance problems or is it safe?

class A {}

function B () {
    if ( !new.target ) {
        return new B();
    }
}

B.prototype = A.prototype;
B.prototype.constructor = B;

A little background: Function B is supposed to be the only part of the library that will be exposed. Ideally it should be possible to use B without new but also use instanceof B to identify objects.

0 Answers0