[Laszlo-user] suggested way to check for class type in Wafflecone?

Elliot Winard enw at laszlosystems.com
Thu Aug 30 08:27:12 PDT 2007


All classes are fields in lz?  Why's that?
That seems kinda odd.
-e

P T Withington wrote:
> On 2007-08-30, at 10:01 EDT, Elliot Winard wrote:
>
>> I have some window management code that iterates through an array of 
>> different windows & switches on the exact window type.
>>
>> It used to work with code like this -
>>           var w=getNextWindow();
>>
>>            // classname can be composewindow, mailwindow, contactswindow
>>            if(w.classname == "composewindow") 
>> {                              return w;
>>            }
>>
>> This stopped working because w.classname is now Object. 
>> w.constructor.classname is, however, 'composewindow'
>>
>> What's the right way to do this?  Should obj.classname be the same as 
>> obj.constructor.classname?
>> I want to make sure this works when & if OpenLaszlo is updated.
>
> I think what you really want to do is say:
>
>   if (w instanceof lz.composewindow) {
>
> The fact that there is a classname property on instances is an 
> accident of Javascript inheritance.


More information about the Laszlo-user mailing list