Unless I'm missing something,
if a in array
unless a in array
should simply compile to
if (~array.indexOf(a))
if (!~array.indexOf(a))
rather than the incredibly contrived
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
if (__indexOf.call(array, a) >= 0)
if (__indexOf.call(array, a) < 0)
What ancient browser are you trying to support that doesn't have indexOf on arrays? At the very least learn what the tilde operator does ;)