我想知道如何判断A类是否来自JavaScript中的B类。这是一个例子,为了清楚起见使用ES6类:
class Animal
{
}
class Dog extends Animal
{
}
class Cat extends Animal
{
}
// ...
function makeAnimalOf(ctor)
{
if (/* ctor derived from Animal */) {
return new ctor;
}
throw "ctor is not derived from Animal";
}
var mrWoofles = makeAnimalOf(Dog);
var mittens = makeAnimalOf(Cat);
makeAnimalOf中我的键控器需要看起来像什么?