Created
August 24, 2017 14:12
-
-
Save codenamejason/543643f52cad963b958bae623f0b1d67 to your computer and use it in GitHub Desktop.
This can be useful to reveal "hidden" properties (properties in the prototype chain which are not accessible through the object, because another property has the same name earlier in the prototype chain). Listing accessible properties only can easily be done by removing duplicates in the array.
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 listAllProperties(o) { | |
| var objectToInspect; | |
| var result = []; | |
| for(objectToInspect = o; objectToInspect !== null; objectToInspect = Object.getPrototypeOf(objectToInspect)) { | |
| result = result.concat(Object.getOwnPropertyNames(objectToInspect)); | |
| } | |
| return result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment