Skip to content

Instantly share code, notes, and snippets.

@michael-mafi
Last active January 11, 2017 00:14
Show Gist options
  • Select an option

  • Save michael-mafi/b532fb9e9f22aa86d4cbed760818fc09 to your computer and use it in GitHub Desktop.

Select an option

Save michael-mafi/b532fb9e9f22aa86d4cbed760818fc09 to your computer and use it in GitHub Desktop.
isPrototypeOf.js
function isPrototypeOf(parent, child){
if (parent === null || undefined){
return false;
}
if (Object.getPrototypeOf(child) === null || undefined){
return false;
}
return Object.getPrototypeOf(child) === parent || Object.prototype ? true: false;
}
isPrototypeOf(dog, myDog); // returns true
isPrototypeOf(dog, empty); // returns false
isPrototypeOf(Object.prototype, myDog); // returns true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment