js中&&和||的運算結果
1)&&表達式中左右都爲真
var a = true;
var b = 'haku';
console.log(a&&b);//haku
結果:返回右邊的值
2)&&表達式中左爲假,右爲真
var a = false;
var b = 'haku';
console.log(a&&b);//false
結果:返回左邊的值
3)&&表達式中左爲真,右爲假
var a = 'yui';
var b = false;
console.log(a&&b);//false
結果:返回右邊的值
4)||表達式中左右都爲真
var a = 'yui';
var b = 'haku';
console.log(a||b);//yui
結果:返回左邊的值
5)||表達式中左爲假,右爲真
var a = false;
var b = 'haku';
console.log(a||b);//haku
結果:返回右邊的值
6)||表達式中左爲真,右爲假
var a = 'yui';
var b = false;
console.log(a||b);//yui
結果:返回左邊的值