与&&一起返回 [英] returning with &&
本文介绍了与&&一起返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
用&&返回值是什么意思?
What does it mean to return a value with &&?
else if (document.defaultView && document.defaultView.getComputedStyle) {
// It uses the traditional ' text-align' style of rule writing,
// instead of textAlign
name = name.replace(/([A-Z]) /g, " -$1" );
name = name.toLowerCase();
// Get the style object and get the value of the property (if it exists)
var s = document.defaultView.getComputedStyle(elem, " ") ;
return s && s.getPropertyValue(name) ;
推荐答案
return a &&b
意思是如果 a 为假则返回 a,如果 a 为真则返回 b".
return a && b
means "return a if a is falsy, return b if a is truthy".
相当于
if (a) return b;
else return a;
这篇关于与&&一起返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文