gpt4 book ai didi

javascript - 使用 && 返回值

转载 作者:行者123 更新时间:2023-12-03 00:12:53 25 4
gpt4 key购买 nike

用&&返回值是什么意思?

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”。

相当于

if (a) return b;
else return a;

关于javascript - 使用 && 返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4490274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com