Last active
August 29, 2015 14:07
-
-
Save brandonvanha/5c9e025e8c6f60e2e50e to your computer and use it in GitHub Desktop.
Iterates over all properties (not just enumerable ones).
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 getAllPropertyNames(obj) { | |
var result = []; | |
while (obj) { | |
// Add the own property names of `obj` to `result` | |
Array.prototype.push.apply(result, Object.getOwnPropertyNames(obj)); | |
obj = Object.getPrototypeOf(obj); | |
} | |
return result; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment