Created
March 14, 2016 22:12
-
-
Save emilioriosvz/d46589c841083fecb734 to your computer and use it in GitHub Desktop.
Get all properties names of an object
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
var getAllProperties = function (object) { | |
var properties = [] | |
do { | |
Object.getOwnPropertyNames(object).forEach((prop) => { | |
if (!~properties.indexOf(prop)) { | |
properties.push(prop) | |
} | |
}) | |
} while (object = Object.getPrototypeOf(object)) | |
return properties | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment