I know that you can obtain a property descriptor object
of a certain property 'prop
' of a certain object obj
with
Object.getOwnPropertyDescriptor(obj,"prop");
.
I was just wondering: Where are these objects stored?
Are they stored internally within an object or .... elsewhere?
I tried to find them in developer tools but with no luck.
Property descriptor objects does not exist unless explicitly requested. They are created ad-hoc when you call Object.getOwnPropertyDescriptor
.
So following code:
var foo = {bar:'foo'}
Object.getOwnPropertyDescriptor(foo, 'bar') === Object.getOwnPropertyDescriptor(foo, 'bar');
Always evaluate to false.
So as we see (both code and specification), property descriptor objects are not stored, but created on demand.
So where are writable
, configurable
, value
, get
, set
... atributtes stored? Specification doesn't require them to be exposed to user code... Here is C++ definition for V8 PropertyDescriptor class - it seems like every property occupy one byte.
And if you want check if property is writable, configurable or similar, Firefox console allow you to do so (but only if property isn't writable or has getter/setter):