I love the Object.getOwnPropertyNames method. It seems like such a useful tool for learning about objects from within a JS shell.
What's driving me nuts, though, is that getOwnPropertyNames seems to be missing some (Note: in my tests I am running an ECMA 5 implementation—Google Chrome version 28.0.1500.95).
Here's an example:
> var x= []
undefined
> x.constructor
function Array() { [native code] }
> Object.getOwnPropertyNames(x)
["length"]
Yet clearly, x has lots of properties! (e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype)
> x.push
function push() { [native code] }
> x.pop
function pop() { [native code] }
Can anyone help explain what's going on here? Thanks! :D
Edit: Okay! I see that getOwnPropertyNames only gets the property names of the object at hand. Is there a simple way to get inherited properties? Or perhaps the only way is to traverse through object.constructor.prototype.__proto__?