WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

 « Return to Thread: Why JS array is not inheriting default properties like length, splice etc

Why JS array is not inheriting default properties like length, splice etc

by rituparna kashyap :: Rate this Message:

| View in Thread

Hi,

I am actually new to both spider monkey api and this mailing list. Actually
I was trying to create a Array like objectA.arrayA and the call back code
goes like this.

        string *value[] = {"abc", "xyz", "efg"};
        int count = 0;
        JSObject* val = JS_NewArrayObject(pContext, 0, NULL);

        while(count < 3) {
            jstr = JS_NewStringCopyZ(pContext, value[count]);

            JS_DefineElement(pContext, val, count++, STRING_TO_JSVAL(jstr),
                            NULL, NULL, JSPROP_ENUMERATE | JSPROP_READONLY
| JSPROP_PERMANENT);
        }

        vJs->DefineProperty(pObject, "arrayA", OBJECT_TO_JSVAL(val));

I am getting the proper value for the objectA.arrayA but when I do
objectA.arrayA.length, it says  arrayA does not have ay property. Can you
tell what i am doing wrong. I am facing the same even when I am creating a
sting.

--
With regards:

*Rituparna Kashyap*
Ph- (+91)-9686232205
Bangalore
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

 « Return to Thread: Why JS array is not inheriting default properties like length, splice etc