How to enumerate object's properties in javascript under SpiderMonkey?

Hello,

How to enumerate object's properties in javascript under SpiderMonkey?
I've tried Object.getOwnPropertyNames(obj) or Object.keys(obj), but nothing was returned, however, the code of the embedded object defines some properties and these could be used.
I have used JS_PSG macro with JSPROP_PERMANENT | JSPROP_ENUMERATE flags set.

Best Regards,
Mike
0
Mihai
1/8/2017 7:32:09 PM
mozilla.dev.tech.js-engine 1990 articles. 0 followers. Post Follow

3 Replies
5 Views

Similar Articles

[PageSpeed] 29

On 1/8/17 2:32 PM, Mihai Dobrescu wrote:
> I've tried Object.getOwnPropertyNames(obj) or Object.keys(obj), but nothing was returned

Those plus Object.getOwnPropertySymbols and Reflect.ownKeys are the 
normal ways to do this, depending on which sorts of properties you want.

> however, the code of the embedded object defines some properties and these could be used.
> I have used JS_PSG macro with JSPROP_PERMANENT | JSPROP_ENUMERATE flags set.

Are the properties defined on the _object_ or on the _prototype_?  All 
the above return own props only, not things off the proto chain.

-Boris
0
Boris
1/9/2017 5:43:25 PM
On Monday, January 9, 2017 at 7:43:31 PM UTC+2, Boris Zbarsky wrote:
> On 1/8/17 2:32 PM, Mihai Dobrescu wrote:
> > I've tried Object.getOwnPropertyNames(obj) or Object.keys(obj), but nothing was returned
> 
> Those plus Object.getOwnPropertySymbols and Reflect.ownKeys are the 
> normal ways to do this, depending on which sorts of properties you want.
> 
> > however, the code of the embedded object defines some properties and these could be used.
> > I have used JS_PSG macro with JSPROP_PERMANENT | JSPROP_ENUMERATE flags set.
> 
> Are the properties defined on the _object_ or on the _prototype_?  All 
> the above return own props only, not things off the proto chain.
> 
> -Boris

On the prototype.
0
Mihai
1/9/2017 7:29:44 PM
On 1/9/17 2:29 PM, Mihai Dobrescu wrote:
> On the prototype.

OK, then you want to ask for the _prototype's_ own props, I would think.

-Boris

0
Boris
1/9/2017 8:09:20 PM
Reply: