Subj : Re: SM typeof for extensions To : Shanti Rao From : Brendan Eich Date : Thu Sep 09 2004 04:50 pm Shanti Rao wrote: > Brendan Eich wrote: >> >> Is this some evil MS-ism? > > > Tee hee. I also have Stream, File, ODBC, and Mail classes. ActiveX was > just first on the list. Wait, I was asking whether you were emulating something JScript does. If you're just looking for a way to distinguish classes of objects, then don't use typeof -- see below. >> With E4X, there may be a general way to change the result of typeof. >> Right now, you'll have to hack jsapi.c. Gross. > > > My workaround is to give the prototype a "className" property. Does > anyone else want to suggest a convention for solving this? The standard has always been, for SpiderMonkey, to test using typeof o == "object" && o != null to decide that o is an object reference, and then to use o.constructor or (SM and Rhino(?) only, an ECMA extensions): o.constructor.name to identify the object's class by its constructor function or constructor function name, respectively. /be .