Created
August 9, 2015 22:57
-
-
Save daniellizik/09fc303a4c71225f06ad to your computer and use it in GitHub Desktop.
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 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