java 脚本或 angularjs 条件检查带有“!”的对象vs "!!"
java script or angularjs condition check on object with "!" vs "!!"
谁能解释一下
的区别
<div ng-show="!user.name">
and <div ng-show="!!user.name">
我想知道
!!
是吗?在 angularjs
我用谷歌搜索但没有得到相关的答案
true
计算为 true
!true
计算为 false
!!true
计算为 true
!!!true
计算为 false
..如果你愿意,你可以继续。
!!
的主要用途通常是取一个 truthy value 并使其产生布尔值 true
或 false
.
logical not operator !
Returns false if its single operand can be converted to true; otherwise, returns true
另见 What is the !! (not not) operator in JavaScript?
谁能解释一下
的区别
<div ng-show="!user.name">
and<div ng-show="!!user.name">
我想知道
!!
是吗?在 angularjs 我用谷歌搜索但没有得到相关的答案
true
计算为true
!true
计算为false
!!true
计算为true
!!!true
计算为false
..如果你愿意,你可以继续。
!!
的主要用途通常是取一个 truthy value 并使其产生布尔值 true
或 false
.
logical not operator
!
Returns false if its single operand can be converted to true; otherwise, returns true
另见 What is the !! (not not) operator in JavaScript?