两种方法:
处理变量为 undefined 的情况:
v = v||null; // 假设 v 为 undefined, 则其值变为 null
双感叹号:!!, 把 null/undifined/0 转换为 bollean 类型
使用方法: if(!!a) {}
当 a=null/undifined/0 时, 推断结果为 false
来源: http://www.bubuko.com/infodetail-2476565.html