Skip to content

Instantly share code, notes, and snippets.

@brandonvanha
Last active August 29, 2015 14:07
Show Gist options
  • Save brandonvanha/5c9e025e8c6f60e2e50e to your computer and use it in GitHub Desktop.
Save brandonvanha/5c9e025e8c6f60e2e50e to your computer and use it in GitHub Desktop.
Iterates over all properties (not just enumerable ones).
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