-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