Last active
January 11, 2017 00:14
-
-
Save michael-mafi/b532fb9e9f22aa86d4cbed760818fc09 to your computer and use it in GitHub Desktop.
isPrototypeOf.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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