[thelist] JS Boolean Object...

Chris Marsh chris at ecleanuk.com
Thu Dec 4 14:59:17 CST 2003


On Thu, 4 Dec 2003 12:53:43 -0600, jsWalter wrote
> I am trying to figure out how I can do this...
> 
> bolValue = someFunc ( someVar );
> 
> if ( bolValue )  // true
>     // do something here
> else
>     alert ( bolValue.err );
> 
> As you can see, I need to define a var as a Boolean and if I have a 
> problem, add a message element to the Object.
> 
> Nothing I do seems to work.
> 
> Anyone know if I'm barking up the wrong tree. again.

>From what I can see you are trying to simultaneously use a boolean-typed 
variable as an object. Would the following work?

var oFoo = new Object();
oFoo.bolValue = someFunc(someValue);
if(oFoo.bolValue) {// true
  // do something here
}
else {
  oFoo.err = "Bar";
}

Perhaps further assistance can be provided if you give a little more detail 
on what you are trying to achieve.

Regards

Chris Marsh


More information about the thelist mailing list