crabdave 发表于 2013-2-7 18:53:05

javascript中的逻辑与或非

javascript中的逻辑与或非
 
Examples
The following code shows examples of the && (logical AND) operator.
a1=true && true       // t && t returns true
a2=true && false      // t && f returns false
a3=false && true      // f && t returns false
a4=false && (3 == 4)  // f && f returns false
a5="Cat" && "Dog"     // t && t returns Dog
a6=false && "Cat"     // f && t returns false
a7="Cat" && false     // t && f returns false
 
The following code shows examples of the || (logical OR) operator.
o1=true || true       // t || t returns true
o2=false || true      // f || t returns true
o3=true || false      // t || f returns true
o4=false || (3 == 4)  // f || f returns false
o5="Cat" || "Dog"     // t || t returns Cat
o6=false || "Cat"     // f || t returns Cat
o7="Cat" || false     // t || f returns Cat
 
The following code shows examples of the ! (logical NOT) operator.
n1=!true              // !t returns false
n2=!false             // !f returns true
n3=!"Cat"             // !t returns false
 
 
http://www.webreference.com/javascript/reference/core_ref/ops.html
页: [1]
查看完整版本: javascript中的逻辑与或非