Parez.. It is an old trick taking advantage of the short circuited &&
operator.
From my old JScript Tutorial
http://www.geocities.com/jeff_louie/helloworld2.htm
Learn More About Short Circuited Logical AND
The logical AND operator, &&, returns true if both the left and right
hand
operand evaluates to boolean true. However, the evaluation is "short
circuited" if the the first operand evaluates to false. Since the result
of the
logical AND operation is known if the left sided operand is false, there
is no
need to actually evaluate the right hand operand. For efficiency, the
right
hand operand is not evaluated if the left hand operand returns false. In
other
words, the evaluation is optimized at compile time. We can use this
"short
circuited" behavior to avoid a run time null pointer exception. Calling
a
method or accessing a property on a null object will throw an exception
at
runtime, unexpectedly crashing the application with the message "Object
reference not set to an instance of an object." Here is the snippet code
in our
project that demonstrates the use of logical AND:
if (message != null && message.length > 0) {
this.message= message;
}
If the user passes a null object to this method, the evaluation is short
circuited and the right hand operand, message.length, is not evaluated
or
executed. Pretty tricky.
Regards,
Jeff