You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
More generally, the operator returns the value of the first falsy operand encountered when evaluating from left to right, or the value of the last operand if they are all truthy.
React 的数据处理
点这里直接看效果 CodeSandBox
&& 在 jsx 中的使用
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND
返回第一个 falsy 值,如果全部 truthy 返回最后一个
Falsy 看这里 https://developer.mozilla.org/en-US/docs/Glossary/Falsy
null
— the absence of any value.undefined
— the primitive value.false
false
.NaN
— not a number.0
Number
zero, also including0.0
,0x0
, etc.-0
Number
negative zero, also including-0.0
,-0x0
, etc.0n
BigInt
zero, also including0x0n
, etc. Note that there is noBigInt
negative zero — the negation of0n
is0n
.""
''
and``
.document.all
document.all
.渲染中 && 和 number 要注意
注意 0 被渲染了,可能不符合你的预期行为
Note
So,一般 jsx 里做渲染判断的值前面加 !! 转化下比较稳
The text was updated successfully, but these errors were encountered: