Deriving from an external class that is implemented using the Javascript class syntax yields browser error "TypeError: class constructors must be invoked with |new|"

The generated code that causes the error is

function Bar() {
    Foo.call(this)
}

The apparent fix is to generate this instead:

function Bar() {
    if (Foo.prototype.hasOwnProperty('constructor')) {
        Foo.constructor.call(this)
    } else {
        Foo.call(this)
    }
}

Well, the user may have manually created a function named ‘constructor’. Perhaps there is a foolproof way to check whether Foo was defined with the class syntax.