两种方法:
- 处理变量为undefined的情况:
v = v||null; //假设v为undefined,则其值变为null
- 双感叹号:!!,把null/undifined/0转换为bollean类型
使用方法:if(!!a) {}
当 a=null/undifined/0时,推断结果为false
(原创文章,转载请注明转自Clement-Xu的csdn博客。
)
两种方法:
(原创文章,转载请注明转自Clement-Xu的csdn博客。
)
原文:https://www.cnblogs.com/llguanli/p/8364898.html