Hiring at Votizen

Just wanted to share that we are hiring at Votizen.com, if you or an engineer you know is looking for a job:

Engineering Job at Votizen
View more presentations from Votizen

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:

var mystr = '...';
if (-1 < mystr.indexOf('test')) {
  //found it
} else {
  //didn't find it
}

with

var mystr = '...';
if (~mystr.indexOf('test')) {
  //didn't find it
} else {
  //found it
}