Skip to content

Instantly share code, notes, and snippets.

@daniellizik
Created August 9, 2015 22:57
Show Gist options
  • Save daniellizik/09fc303a4c71225f06ad to your computer and use it in GitHub Desktop.
Save daniellizik/09fc303a4c71225f06ad to your computer and use it in GitHub Desktop.
function getKeys(obj) {
if (Object.prototype.toString.call(obj) !== "[object Object]") return;
return recurse(obj, []);
function recurse(obj, tmp) {
for (var p in obj) {
if (tmp.indexOf(p) === -1) tmp.push(p);
if (Object.prototype.toString.call(obj[p]) === "[object Object]") recurse(obj[p], tmp);
}
return tmp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment