JavaScript!和 !!差异
可能的重复:
什么是!! JavaScript 中的运算符?
这两个运算符有什么区别?做 !!有特殊含义,或者只是意味着您正在做两个“!”运营。我知道 Javascript 中有“Truth”和“Truthy”概念,但我不确定是否有!!是为了“真理”
Possible Duplicate:
What is the !! operator in JavaScript?
What is the difference between these two operators? Does !! have special meaning, or does it simply mean you are doing two '!' operations. I know there are "Truth" and "Truthy" concepts in Javascript, but I'm not sure if !! is meant for "Truth"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
!!只是双倍!
!!是将某些内容转换为布尔值的常见方法
!! is just double !
!! is a common way to cast something to boolean value
编写
!!
是将“true”或“falsey”变量转换为真正布尔值的常见方法。例如:
第一个
!
应用于foo
后,返回值为true
。再次注意到该值会使其成为false
,这意味着if
块内的代码不会被输入。Writing
!!
is a common way of converting a "truthy" or "falsey" variable into a genuine boolean value.For example:
After the first
!
is applied tofoo
, the value returned istrue
. Notting that value again makes itfalse
, meaning the code inside theif
block is not entered.