一、!的作用
!可将变量转换成boolean类型,null、undefined和空字符串取反都为false,其余都为true。
!null=true
!undefined=true
!''=true
!100=false
!'abc'=false
二、!!的作用
!!常常用来做类型判断
var a;
if(a!=null && typeof(a)!=undefined && a!=''){
//a有内容才执行的代码
}
可以简化为:
if (!!a) {}