Binary search on string in alphabetical order
Binary search is usually simpler:

function binarySearch(haystack, needle) {
    var a = 0;
    var b = haystack.length - 1;
    if (needle &lt; haystack[0] || needle &gt; haystack[b]) {
        return false;
    }
    while (a &lt; b - 1) {
        var c = (a + b) / 2 |0;
        if (needle &lt; haystack[c]) {
            b = c;
        } else {
            a = c;
        }
    }
    return haystack[a] === needle || haystack[a+1] === needle;
}