Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
551 views
in Technique[技术] by (71.8m points)

operators - What does the '!!!' syntax mean in javascript?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...