Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下语句没有if语句,即使它使用了?字符。它如何评价?
if
?
var username = req.user ? req.user.username : '';
这相当于:
var username; if (req.user) { username = req.user.username; } else { username = ''; }
在 MDN 上阅读有关三元运算符的更多信息。