code: function binarySearch(array, value, comparer) {
          if (!array || array.length === 0) {
              return -1;
          }
          var low = 0;
          var high = array.length - 1;
          comparer = comparer !== undefined
              ? comparer
              : function (v1, v2) { return (v1 < v2 ? -1 : (v1 > v2 ? 1 : 0)); };
          while (low <= high) {
              var middle = low + ((high - low) >> 1);
              var midValue = array[middle];
              if (comparer(midValue, value) === 0) {
                  return middle;
              }
              else if (comparer(midValue, value) > 0) {
                  high = middle - 1;
              }
              else {
                  low = middle + 1;
              }
          }
          return ~low;
      }
docs: Performs a binary search, finding the index at which 'value' occurs in 'array'.
  If no such index is found, returns the 2's-complement of first index at which
  number[index] exceeds number.
  @param array A sorted array whose first element must be no larger than number
  @param number The value to be searched for in the array.