[thelist] check existence of a javascript function

.jeff jeff at members.evolt.org
Thu Jan 24 13:42:00 CST 2002


liorean,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Liorean
>
> > if(opener.getAppId?true:false) {
> >   ...
> > }
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

the '?true:false' bit is unnecessary, redundant, and makes your code
difficult to read and maintain.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Also, the "?true:false" in the first case bit can be
> left out, but that's a bad habit.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

that's only a bad habit when assigning a boolean value to a variable:

var isIE = (document.all) ? true : false;

however, when in a conditional statement, it's assumed that expressions will
return either true or false and therefore unnecessary to perform your own
comparison first.  when you consider that the ternary operator is really
just a shorthand if/else statement, i think you'll see my point.

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/





More information about the thelist mailing list