Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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);
}
@alexkirsz

This comment has been minimized.

Copy link

@alexkirsz alexkirsz commented Apr 27, 2015

Won't this line always return false?

@elierotenberg

This comment has been minimized.

Copy link
Owner Author

@elierotenberg elierotenberg commented Apr 27, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment