Created
January 11, 2017 01:51
-
-
Save ugovaretto/a776c6ca2d14fbf6b30a34bf38035d0a to your computer and use it in GitHub Desktop.
List all properties of JavaScript objects
This file contains 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