什么是'!!!'语法在javascript中意味着什么? [英] What does the '!!!' syntax mean in javascript?

查看:4402
本文介绍了什么是'!!!'语法在javascript中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在其中一个Windows应用商店示例中遇到了以下代码行。

I just came across the following line of code in one of the Windows Store Apps samples.

if (that.assets[asset].object === null || !!!that.assets[asset].object.canPlayType) {

它使用三重感叹号语法。我做了一些测试(我很确定我错过了什么),结果总是一样的。我认为它有点相当于 === !== ...

It uses a triple exclamation mark syntax. I've done some testing (and I'm pretty sure I missed something), and the result is always the same a single !. I assumed it was somewhat equivalent to === and !==...

任何人都可以解释 !!! 语法的含义吗?

Can anyone explain what the !!! syntax means?

推荐答案


我认为它有点等同于===和!== ......

I assumed it was somewhat equivalent to === and !==...

不,它只是三个非运​​营商,不是不是。

No, it's just three "not" operators, a "not-not-not".

它与!(!(!(x)))相同,并且总是相当于一个!x

It's the same as !(!(!(x))), and is always equivalent to a single !x.

这对此毫无用处。 !! 是将任何变量转换为其布尔表示的有点神秘的方法,但 !!! 只是愚蠢。你可以将任意数量的连在一起,但它对任何东西都没用。

There is literally no use for this. !! is a somewhat cryptic means of converting any variable to its boolean representation, but !!! is just silly. You can chain an arbitrary number of !'s together, but it isn't useful for anything.

这篇关于什么是'!!!'语法在javascript中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆