Subj : Re: JS_GetClass won't return proper class name. To : Mike Moening From : Brendan Eich Date : Tue Mar 29 2005 02:31 pm Mike Moening wrote: > No I used "new". > The original post has the entire code. That code is evaluated using the > global object. > Any more ideas? Did you debug even a little? You could put a print(this); at the top of that script, and a print(this); at the top of Factorial's body, for example. I did that, and here's what I see: [object global] [object Object] That proves that |this| binds correctly to the new object when your script calls new Factorial(). As expected, therefore, n and results are not defined on the global object: js> n typein:1: ReferenceError: n is not defined js> results typein:2: ReferenceError: results is not defined So you're not showing me all your cards ;-). /be > > Mike M. > > "Brendan Eich" wrote in message > news:d2c9hb$p423@ripley.netscape.com... > >>Mike Moening wrote: >> >>>In short here is what I did: >>> >>>ctor = JS_GetConstructor(cx, JS_GetPrototype(cx, obj)); >> >> >>Note that you could pass obj to JS_GetConstructor directly, so long as >>obj doesn't "shadow" the prototype 'constructor' property with a >>different-valued one of the same name. >> >> >> >>>Unfortunately the "results" and "n" properities show up in the > > properties > >>>listing twice. >>>Once standing alone and once under the Factorial "object" when I > > recursively > >>>call GetPropertyDescArray() on the object. >> >> >>The only reason n and results could show up on the global object is >>because you call Factorial() directly (no operator new). Do you do >>that? If you do, then |this| binds (as usual) to the global object -- >>the object in which 'Factorial' was found on the scope chain. >> >>/be > > > .