Additionally, I read this great article by Timmy Willison about some of the Rare JavaScript Operators, and the performance costs of some well-known operators. Two parts of this article really struck me, first the performance of == versus ===, and second the ~ operator. In short (except marginally in FireFox 4, which has a special optimization for comparisons), it is always faster to use === instead of == if type coersion is going to occur, and even when coersion doesnt occur it is still usually faster to use === , and never slower.

The statement ~N is the same as -(N+1), which isnt terribly useful, until you consider the value -1, which is returned as a failure of indexOf functions. See, ~-1 is equals to zero, which is falsy, so ~some haystack.indexOf(some needle) will return false if the value is not found. This means you can replace: