Skip to main content

逻辑非运算符

!运算符可以将变量取反转换成 boolean 型,像 0、undefined 这种名义上为否的变量取反都为 true,其余的用!为 false

!0 = true
!undefined = true
!'' = true
!null = true
!'x' = false
!999 = false

!! 逻辑非的取反运算

!!通常用来做类型判断,就是双重否定等于肯定的意思

新手

判断 plugin 为非空,定义或者非空串时执行 read 函数