How to check if a Javascript Class inherits another (without creating an obj)?

前端 未结 5 545
别那么骄傲
别那么骄傲 2020-11-29 03:12

Eg:

function A(){}
function B(){}
B.prototype = new A();

How can I check if the class B inherits class A?

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 03:37

    back to 2017:
    check if that work for you

    ParentClass.isPrototypeOf(ChildClass)
    

提交回复
热议问题