[thelist] JS Boolean Object...

jsWalter jsWalter at torres.ws
Thu Dec 4 17:46:10 CST 2003

> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org]On Behalf Of James Aylard
> Sent: Thursday, December 04, 2003 3:24 PM
> To: thelist at lists.evolt.org
> Subject: Re: [thelist] JS Boolean Object...

> Have someFunc return a Boolean value, either true or false (or
> else a value than can be evaluated to either true or false [1]):
> function someFunc(myVar)
> {
>   if ("Blue" == myVar)
>   {
>     return true ;
>   }
>   return false ;
> }

Yes, very standard way of doing this.

But what this does not do is tell me why this operation failed.

that as the point. I wanted my cake and eat it too.

> 1. Keep in mind that any expression that evaluates to 0, null,
> undefined, or an empty string is interpreted as false, and that
> any expression that evaluates to any other value is interpreted
> as true. So, in the example that you provided in your second post
> -- where you evaluated "true" as a string value -- both "true" and
> "false", as strings, will evaluate to true, which
> you almost certainly don't want.

right. But my second example also showed that the value was being excplitly
defined, so a null/undefined value would not be returned.



More information about the thelist mailing list