Created
June 15, 2011 18:53
-
-
Save Rob-ot/1027804 to your computer and use it in GitHub Desktop.
javascript tilde operator with indexOf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> var a = ["a", "b"] | |
> a.indexOf("a") | |
0 | |
> a.indexOf("b") | |
1 | |
> a.indexOf("c") | |
-1 | |
> ~a.indexOf("a") | |
-1 | |
> ~a.indexOf("c") | |
0 | |
> !!~a.indexOf("a") | |
true | |
> !!~a.indexOf("c") | |
false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I guess this shows just how much browsers (and computers in general) have improved in just a few years!
Chrome on Windows 7