2016-08-18 77 views
-3

我发现这个地方:而不是if (count != undefined && count != null),使用if(count != null)。可以交替使用if (count == null)if(!count)吗?(count!= null)vs if(!count)in javascript

+1

'count!= undefined && count!= null'与* count!= null完全相同。如果'count'为'null','undefined','0','NaN',空字符串或'false',则'count'为true。 (当我寻找重复时转换为答案) – Ryan

+0

https://dorey.github.io/JavaScript-Equality-Table/ – Nit

回答

5

count != undefined && count != null恰好是count != null相同。 !count如果countnull,undefined,0,NaN,空字符串或false为真。