This is a bitwise NOT , although its use here is rather opaque.
It is used to convert the result of -1 from indexOf (i.e., the string not found) to 0 , which is a false value (since ~-1 == 0 and 0 is false in the boolean context), and it allows all other values ββto remain believable.
Could this be written more clearly as (type.indexOf('/') != -1) ? ... : ... (type.indexOf('/') != -1) ? ... : ...
In plain English, it says: "Handle the result -1 (i.e. if / not found) from indexOf as false , otherwise treat the result as true ."
apsillers
source share