Yesterday, I looked through the examples of Raphaël and found the following line of code in an animation demo:
+!!(this.cx - 100)
I was baffled by the sheer amount of operators in front of the brackets. What do they actually do? So I switched to WriteCodeOnline and typed in some examples. The following table presents the results:
value | ! | !! | +!! |
---|---|---|---|
undefined | true | false | 0 |
null | true | false | 0 |
0 | true | false | 0 |
number != 0 | false | true | 1 |
So, the sole purpose of +!!
is to get a 0
or 1
from whatever value is passed to it.
Leave a comment
Comments feed for this article