On 2006-05-12, at 08:48 PDT, Dan Stowell wrote:
>> But that's what we're doing for now, right? If I parse out your
>> full explanation ("How to determine if a property exists"), I
>> think that's one of the two idioms you are referring to at the end
>> of the message :-)
>
> It's all over production code, so I'd say we're using it right now.
> It's a bad idiom though. Correct me if I'm wrong, but won't the
> following snippet execute the else close if args[height] is null OR
> is zero?
>
> if ( args[height] ) {
> ...
> } else {
> // code that assumes args[height] is null, when it's really 0
> }
>
> I once spent a day tracking down a nasty bug that resulted from the
> empty string causing an if clause to fail (which is strange,
> because strings are objects in ECMA, right?). Overloading if and
> the boolean operators reduces typing, but can lead to these kinds
> of headaches. Sigh.
ECMA defines that the undefined value, `null`, `false`, `0` and `""`
all coerce to false in a boolean context.
Cf., http://pt.withy.org/ptalk/archives/2005/06/
dont_assume_undefined_is_undefined.html
_______________________________________________
Laszlo-dev mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-dev