js中的!!

js中的!一般做取反用
一般取反获得true的有

!null=true
!''=true
!0=true
!undefined=true

!!的用法

正常判断对象a不为空的代码

if(a!=null&&typeof(a)!=undefined&&a!=''){
    //a不为空
}

!!处理就简单很多了

if(!!a){
    //a不为空
}

猜你喜欢

转载自blog.csdn.net/qq_29913805/article/details/86687134
今日推荐