logical.js

来自「这是《JavaScript学习源代码》一书的源代码」· JavaScript 代码 · 共 17 行

JS
17
字号
var a =  true;				//set two boolean values
var b = false; 

var result = "a = " + a + " b = " + b;	//store the current values

var both_test = ( a && b ); 		// test if both operands are true
result += "\n\nAre both values true? = " + both_test; //store the result

var either_test = ( a || b );  		// test if either operand is true
result += "\n\nIs either value true? = " + either_test; //store the result
 
a = !a ;    				// toggle both stored values
b = !b;

result += "\n\na = " + a + " b = " + b;	//store the current values

alert( result );			//display the stored info 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?