var _ = ((obj.fn && obj.fn() ) || obj._ || ( obj._ == {}))? true: false将返回布尔值。
更新
请注意,这是基于我的测试。我不会被完全依赖。
它是一个 不 赋值
true或 不 赋值的表达式
false。而是分配计算的值。
让我们看一下这个表达式。
表达式示例:
var a = 1 || 2;// a = 1// it's because a will take the value (which is not null) from leftvar a = 0 || 2;// so for this a=2; //its because the closest is 2 (which is not null)var a = 0 || 2 || 1; //here also a = 2;
您的表情:
var _ = (obj.fn && obj.fn() ) || obj._ || ( obj._ = {} );// _ = closest of the expression which is not null// in your case it must be (obj.fn && obj.fn())// so you are gettig this另一个表达:
var a = 1 && 2;// a = 2var a = 1 && 2 && 3;// a = 3 //for && operator it will take the fartest value// as long as every expression is truevar a = 0 && 2 && 3;// a = 0
另一个表达:
var _ = obj && obj._;// _ = obj._



