Subj : Re: How to access the properites. To : Chris Du From : Brendan Eich Date : Sat Jan 29 2005 01:51 pm Chris Du wrote: > I used the following method to define an object and its properties & > methods: > * it = JS_DefineObject(cx, glob, "it", &its_class, NULL, 0); > if (!it) > return 1; > if (!JS_DefineProperties(cx, it, its_props)) > return 1; > if (!JS_DefineFunctions(cx, it, its_methods)) > return 1; OK, *this* message belongs in the jseng newsgroup, because you are not asking about document.all, or anything to-do with the Document Object Model. See newsgroup: and followup-to: headers, again. > * > If I use the following code: > *print(it.color); // color is one of the properties.* > *print(it.item()); // item is one of the methods.* > > js.exe prints out > *undefined* > *[object It]* > > My *question* is why js.exe can not find object "it"'s properties like > "color"? > BTW, [object It] is the correct message. The js.exe program finds it.color just fine, but it.color has no predefined value, so defaults to undefined. /be > > The definition of "it"'s properties are as follows: > *enum its_tinyid { > ITS_COLOR, ITS_HEIGHT, ITS_WIDTH, ITS_FUNNY, ITS_ARRAY, ITS_RDONLY, > ITS_MY > };* > ** > *static JSPropertySpec its_props[] = { > {"color", ITS_COLOR, JSPROP_ENUMERATE}, > {"height", ITS_HEIGHT, JSPROP_ENUMERATE}, > {"width", ITS_WIDTH, JSPROP_ENUMERATE}, > {"funny", ITS_FUNNY, JSPROP_ENUMERATE}, > {"array", ITS_ARRAY, JSPROP_ENUMERATE}, > {"rdonly", ITS_RDONLY, JSPROP_READONLY}, > {0} > };* > Thank you very much. .