Created
May 30, 2011 07:11
-
-
Save NV/998546 to your computer and use it in GitHub Desktop.
How can I get all keys of an object (including enumerable:false)?
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 obj = {}; | |
Object.defineProperty(obj, "x", {value: 42, enumerable: false}); | |
Object.defineProperty(obj.__proto__, "y", {value: 63, enumerable: false}); | |
for (var key in obj) console.log(key) | |
// nothing | |
Object.keys(obj) | |
// [] | |
Object.getOwnPropertyNames(obj) | |
// ["x"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Object.getOwnPropertyNames
P.S. In addition see my
Object.forAll
enumeration method: https://gist.github.com/367080/Dmitry.