In JScript, these logical operations are all about whether an expression is "meaningful"
For example, 0, "", null, false, undefined, NaN... etc. are all meaningless..
&& will return true or false
and a||b is, if a makes sense, it returns a, otherwise it returns b
So sometimes, I don't write code like this:
var obj=QuerySomeObject();
if(obj==null)return null;
return ;
I'll write it
return (QuerySomeObj()||{}).Property;
Also, pay attention to the comparison between null and false.
0 "" Equation and false are equal when comparing ==.
But null is different. For example
if(!null)
{
alert(1);
}
if(null==false)
{
alert(2);
}
Tested in Firefox, the results are the same!