1 var alltrue = [true, true, true];// false
2 var allfalse = [false, false, false];// false
3 var chaos = [true, false, true, false];// true
4 //1,logic operation;2,shorten-cycle;
5 function LogicXOR(){
6 var args = arguments;
7 if (args.length == 1) {
8 if (args[0].length) {
9 args = args[0];
10 }
11 else {
12 return args[0];
13 }
14 }
15
16 var count = args.length;
17 while (--count > 0) {
18 if (!args[count] !== !args[count - 1])
19 return true;
20 }
21 return false;
22 }
23
24 alert(LogicXOR(alltrue))
25 alert(LogicXOR(allfalse))
26 alert(LogicXOR(chaos))
27 alert(LogicXOR(true, true, true))
28 alert(LogicXOR(false, false, false))
29 alert(LogicXOR(true, false, true, false))