使用 !! ng-show 中作用域变量前的符号代表这个 (!!) 符号
using !! symbol before the scope variable in ng-show what would represent this ( !! )symbol
angularjs 中作用域变量前使用 (!) 的真正含义是什么?
ng-show="!!文件"。如果我在 angularjs ng-directives
中使用这个符号会表示什么
发件人:https://developer.mozilla.org/en-US/docs/Glossary/Truthy
In JavaScript, a truthy value is a value that is considered true when evaluated in a Boolean context. All values are truthy unless they are defined as falsy (i.e., except for false, 0, "", null, undefined, and NaN).
!只是一个 "not",但它具有将任何真值更改为假布尔值并将任何假值更改为真布尔值的效果。当你 bang-bang 一个变量时,你基本上是根据它的 truthy/falsy 行为将它转换成 true 真正的布尔值。这通常是一个很好的做法,但并非完全必要。
!用于反向布尔值和 !! double reverse Boolean,请在此处查看:Click
!!
用作 shorthand 将值转换为显式布尔值。
如果 file
是 "truthy",!!file
将是 true
。如果是 "falsy",!!file
将是 false
。
var nonEmptyString = "nonempty string";
var emptyString = "";
console.log(!!nonEmptyString);
console.log(!!emptyString);
在您的示例中使用 !!
是多余且毫无意义的,因为 ng-show
将负责检查值是 "truthy" 还是 "falsy"。
var nonEmptyString = "nonempty string";
var emptyString = "";
console.log(!!nonEmptyString);
console.log(!!emptyString);
angularjs 中作用域变量前使用 (!) 的真正含义是什么? ng-show="!!文件"。如果我在 angularjs ng-directives
中使用这个符号会表示什么发件人:https://developer.mozilla.org/en-US/docs/Glossary/Truthy
In JavaScript, a truthy value is a value that is considered true when evaluated in a Boolean context. All values are truthy unless they are defined as falsy (i.e., except for false, 0, "", null, undefined, and NaN).
!只是一个 "not",但它具有将任何真值更改为假布尔值并将任何假值更改为真布尔值的效果。当你 bang-bang 一个变量时,你基本上是根据它的 truthy/falsy 行为将它转换成 true 真正的布尔值。这通常是一个很好的做法,但并非完全必要。
!用于反向布尔值和 !! double reverse Boolean,请在此处查看:Click
!!
用作 shorthand 将值转换为显式布尔值。
如果 file
是 "truthy",!!file
将是 true
。如果是 "falsy",!!file
将是 false
。
var nonEmptyString = "nonempty string";
var emptyString = "";
console.log(!!nonEmptyString);
console.log(!!emptyString);
在您的示例中使用 !!
是多余且毫无意义的,因为 ng-show
将负责检查值是 "truthy" 还是 "falsy"。
var nonEmptyString = "nonempty string";
var emptyString = "";
console.log(!!nonEmptyString);
console.log(!!emptyString);