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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Mihai Dobrescu
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
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Boris Zbarsky
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
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Mihai Dobrescu
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.
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Boris Zbarsky
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

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Loading...