Where are property descriptor objects stored?

I know that you can get the property descriptor object of a specific property ' prop ' of a specific obj object with Object.getOwnPropertyDescriptor(obj,"prop"); . I'm just wondering: where are these objects stored? Are they stored inside the facility or ... in another place? I tried to find them in the developer tools, but no luck.

+6
source share
1 answer

Object descriptor objects do not exist unless explicitly requested. They are created ad-hoc when you call Object.getOwnPropertyDescriptor . So the following code:

 var foo = {bar:'foo'} Object.getOwnPropertyDescriptor(foo, 'bar') === Object.getOwnPropertyDescriptor(foo, 'bar'); 

Always evaluate to false.

So, as we see (both the code and the specification), the objects of the property descriptor are not saved, but are created on demand.

So where are writable , configurable , value , get , set ... stored attributes? The specification does not require that they be exposed to user code ... Here is the C ++ definition for the PropertyDescriptor V8 class - it seems that each property takes up one byte.

And if you want to check whether the property is writable, configured, or similar, the Firefox console allows you to do this (but only if the property is not writable or has getter / setter): Firefox devtools

+1
source

All Articles