-3
我发现这个地方:而不是if (count != undefined && count != null)
,使用if(count != null)
。可以交替使用if (count == null)
和if(!count)
吗?(count!= null)vs if(!count)in javascript
我发现这个地方:而不是if (count != undefined && count != null)
,使用if(count != null)
。可以交替使用if (count == null)
和if(!count)
吗?(count!= null)vs if(!count)in javascript
count != undefined && count != null
是恰好是与count != null
相同。 !count
如果count
为null
,undefined
,0
,NaN
,空字符串或false
为真。
'count!= undefined && count!= null'与* count!= null完全相同。如果'count'为'null','undefined','0','NaN',空字符串或'false',则'count'为true。 (当我寻找重复时转换为答案) – Ryan
https://dorey.github.io/JavaScript-Equality-Table/ – Nit