isExtensionOf
// is A an extension of B ? | |
// ex: | |
// class C extends Oject {} | |
// class B extends C {} | |
// class A extends B {} | |
// isExtension(A, B) === true | |
// isExtension(A, C) === true | |
// isExtension(A, Object) === true | |
// isExtension(B, A) === false | |
function isExtensionOf(A, B) { | |
if(A === B) { | |
return true; | |
} | |
if(typeof A !== 'function') { | |
return false; | |
} | |
if(typeof B !== 'function') { | |
return A.__proto__ === B; | |
} | |
return isExtensionOf(A.__proto__, B); | |
} |
This comment has been minimized.
This comment has been minimized.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Won't this line always return false?